Examples TOCexamples

Display handler - part 5.

$Date: 2004/08/07 14:28:59 $

 Table of contents

Introduction

This example requires :


This example will show you how to ignore some html_progress api errors.

An error was volontary made on call of setAnimSpeed method (lines 14 and 22). We have decided to ignore API exception (lines 4 thru 10 and 11), so only lines 24 thru 24 will be executed to catch PEAR_Error.

There is only one error into stack, this one raised at line 22.

display_errors

Print out errors (as a part of the output). For production web sites, you're strongly encouraged to turn this feature off, and use error logging instead. Keeping display_errors enabled on a production web site may reveal security information to end users, such as file paths on your Web server, your database schema or other information.

1 <?php ini_set('display_errors', false); ?>

log_errors

Log errors into a log file (server-specific log, stderr, syslog ...) As stated above, you're strongly advised to use error logging in place of error displaying on production web sites.

1 <?php ini_set('log_errors', true); ?>

 Render options

Default options below are used :

Only option changed is :

Legend for lineFormat: Legend for contextFormat:

[Top]

 Output

Error: invalid input, parameter #1 "$delay" was expecting "less or equal 1000", instead got "10000" in html_progress::setanimspeed (file d:\php\pear\html_progress\examples\errorstack\secure\display_errors-p5.php at line 22)

Catch PEAR_Error API error

[pear_error: message="invalid input, parameter #1 "$delay" was expecting "less or equal 1000", instead got "10000"" code=-100 mode=return level=notice prefix="" info="Array"]

[Top]

 PHP source syntax highlight

  1. <?php
  2. require_once 'HTML/Progress.php';
  3.  
  4. function _pushCallback($err)
  5. {
  6.     // now don't die if the error is an exception, it will be ignored
  7.     if ($err['level'] == 'exception') {
  8.         return HTML_PROGRESS_ERRORSTACK_IGNORE;
  9.     }
  10. }
  11. $logger['push_callback'] = '_pushCallback';
  12.  
  13. $bar = new HTML_Progress($logger);
  14. $e = $bar->setAnimSpeed('100');   // < - - - will generate an API exception
  15.  
  16. if (is_object($e)) {
  17.     if (is_a($e,'PEAR_Error')) {
  18.         die('<h1>Catch PEAR_Error API exception</h1>'.$e->toString());
  19.     }
  20. }
  21.  
  22. $e = $bar->setAnimSpeed(10000);   // < - - - will generate an API error
  23.  
  24. if (is_object($e)) {
  25.     if (is_a($e,'PEAR_Error')) {
  26.         die('<h1>Catch PEAR_Error API error</h1>'.$e->toString());
  27.     }
  28. }
  29. ?>

[Top]