PEAR logo

HTML_CSS : The Definitive Guide

Chapter 10. Error Handler

Table of Contents

Introduction
Configuring a Handler
Controlling error generation
Error Context Display
Custom Error Message Generation
Option: message_callback
Option: context_callback

Introduction

The HTML_CSS 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_CSS API error (basic or exception) will raise a HTML_CSS_Error object that will be return to call script (user script).

[Tip] Tip

Easy to distinct basic PEAR_Error from other PEAR packages to HTML_CSS errors, even if there is a better and more robust solution: HTML_CSS::isError(). But also provide a unique way to retrieve the level of error (warning, error, exception) with the HTML_CSS_Error::getLevel() method.

As usual you can use the PEAR error API as well.

  1. <?php
  2. require_once 'HTML/CSS.php';
  3.  
  4. $css = new HTML_CSS();
  5.  
  6. $result = $css->setStyle('div', 'color', 5);
  7. if (PEAR::isError($result)) {
  8.     // do something when an error is raised
  9. }
  10. ?>

and output to screen will give something like :

Exception1: invalid input, parameter #3 "$value" was expecting "string",
instead got "integer"2 in html_css->setstyle (file [path_to]\[filename] on line 6)3
     
1

error level

2

message body with context informations

3

call context

Perhaps this standard behavior is not what you want. Don't worry, you can change everything :

  • display or ignore the error
  • display or hide part of message (error level, body, context)
[Important] Important

HTML_CSS obey at display_errors and log_errors protocol

HTML_CSS : The Definitive Guide v 1.5.0 : January 15, 2008