![]() HTML_Progress2 : The Definitive Guide
|
Table of Contents
After many rewrites, the new error management adding to this major version of HTML_Progress2 provides again more than in branch 1.x
The HTML_Progress2 package is implemented with a flexible error handler plug-in system. You may use any error handler that you want. Using
PEAR_Error
object (default), but also the
PEAR_ErrorStack
package, or any other error handler you might want to plug in.
Without any configuration, each HTML_Progress2 API error (basic or exception) will raise a
HTML_Progress2_Error
object that will be return to call script (user script).
![]() |
Note |
---|---|
In HTML_Progress 1.x each API error returns a basic
PEAR_Error object.
|
![]() |
Tip |
---|---|
Easy to distinct basic PEAR_Error from other PEAR packages to HTML_Progress2 errors, even if there is a better and more robust solution:
HTML_Progress2::hasErrors() . But also provide a unique way to retrieve the level of progress error (warning, error, exception) with the
HTML_Progress2_Error::getLevel()
method.
|
As usual, to check an error, you can use the PEAR error API :
<?php require_once 'HTML/Progress2.php'; $meter = new HTML_Progress2(); $result = $meter->setValue('37'); if (PEAR::isError($result)) { // do something when an error is raised $error =& $result; } ?>
as well as with :
<?php require_once 'HTML/Progress2.php'; $meter = new HTML_Progress2(); $result = $meter->setValue('37'); if ($meter->hasErrors() > 0) { // do something when an error is raised $error = $meter->getError(); } ?>
which provide a portable solution, and output to screen will give something like :
Perhaps this standard behavior is not what you want. Don't worry, you can change everything :
![]() |
Important |
---|---|
HTML_Progress2 obey at display_errors and log_errors protocol, while HTML_Progress 1.x obey at error_reporting protocol. |
HTML_Progress2 : The Definitive Guide | v 1.0.0 : September 23, 2005 |