Class RSErrorManager

Description

Implementation of an Error Management System.

Please see the docmentation for details.

  • version: 0.1.9
  • copyright: Lukas Feiler 2003
  • author: Lukas Feiler

Located in /code/framework/RSErrorManager/RSErrorManager.php (line 41)


	
			
Direct descendents
Class Description
RSDEngineErrorManager RSDEngineErrorManager implements an error management for the RSDEngine.
Variable Summary
Method Summary
RSErrorManager RSErrorManager ([String $newOperation = 'unspecified operation'])
void catch (PEAR_Error $pearError)
int countErrors ([mixed $conditions = false])
int countErrorsByProperty (mixed $property)
boolean errorsOccurred ([mixed $conditions = false])
void errorsOccurredOnProperty (mixed $property)
void getErrors ([Array $conditions = false])
boolean isRSError (mixed $error)
void onDBError (DB_Error $dbError)
void onFatalError (PEAR_Error $pearError)
void onPermissionDenied (PEAR_Error $pearError)
RSError raiseRSError (String $object, String $property, String $operation, [mixed $message = null], [int $code = null], [int $mode = null], [mixed $options = null], [bool $skipmsg = false])
void reportError (PEAR_Error $pearError)
void reset (String $newOperation)
Variables
String $_currentOperation = 'undefined' (line 47)

The name of the current operation.

  • access: private
Array $_errors = array() (line 53)

An array holding all errors that occurre - the error stack.

  • access: private
Methods
Constructor RSErrorManager (line 62)

Constructor method.

Calls reset to clear the error stack.

RSErrorManager RSErrorManager ([String $newOperation = 'unspecified operation'])
  • String $newOperation: The current operation - the default value for the property 'operation' of raised errors.
catch (line 76)

Saves the error passed as argument on the error stack.

If the error does not define the property operation or if it is set to null the current operation is assigned to this property.

void catch (PEAR_Error $pearError)
  • PEAR_Error $pearError: An instance of the class PEAR_Error or a class that extends it (RSError for example).

Redefined in descendants as:
countErrors (line 215)

Returns the number of occurred errors that match the conditions passed as agrument.

This method calls getErrors. Please see getErrors for writing conditions for fetching errors from the stack.

int countErrors ([mixed $conditions = false])
  • mixed $conditions: An associative array with key-value-pairs. If $conditions is false all errors are counted. This argument is optional. The default is false.
countErrorsByProperty (line 246)

Returns the number of occured errors that were related to the property passed as argument.

This method calls countErrors.

int countErrorsByProperty (mixed $property)
  • mixed $property: Any value. It will be compared using ==.
errorsOccurred (line 233)

Returns true if errors occurred that match the conditions passed as argument.

Note that the error stack can be cleaned by calling the method reset. Please see getErrors for writing conditions for fetching errors from the stack. errorsOccurred calls countErrors.

boolean errorsOccurred ([mixed $conditions = false])
  • mixed $conditions: An associative array with key-value-pairs. If $conditions is false this method returns true if any errors occured. This argument is optional. The default is false.
errorsOccurredOnProperty (line 262)

Returns true if any errors occured on the property $property.

This method calls countErrorsByProperty.

void errorsOccurredOnProperty (mixed $property)
  • mixed $property: This value will be used for comparison (==).
getCurrentOperation (line 271)

Returns the name of the current/default operation.

  • return: The name of the current operation.
String getCurrentOperation ()
getErrors (line 186)

Returns an Array containing all errors from the error stack that match the specified conditions.

If no conditions are specified all errors are returned from the stack. Conditions can be specified by passing an associative array with key-value-pairs. The following returns an array containing all errors that occurred on the object 't_user' and the property 'f_username' while performing the operation 'insert'.


1 $rsErrorManager->getErrors(array(
2 'object' => 't_users',
3 'property' => 'f_username',
4 'operation' => 'insert'
5 )
6 );

void getErrors ([Array $conditions = false])
  • Array $conditions: An associative array with key-value-pairs.
isRSError (line 318)

Returns true if the passed object is an instance of RSError.

  • return: True if the passed object is an instance of RSError, otherwise false.
boolean isRSError (mixed $error)
  • mixed $error
onDBError (line 109)

Handle the occurence of DB errors.

This method gets called by catch.

void onDBError (DB_Error $dbError)
  • DB_Error $dbError
onFatalError (line 121)

Handle the occurence of fatal errors.

This method gets called by catch.

void onFatalError (PEAR_Error $pearError)
  • PEAR_Error $pearError

Redefined in descendants as:
onPermissionDenied (line 134)

Handle the occurence of permission-denied errors.

This method gets called by catch.

void onPermissionDenied (PEAR_Error $pearError)
  • PEAR_Error $pearError
raiseRSError (line 304)

This method is a wrapper for PEAR::raiseError. It returns an instance of the class RSError.

In comparison to PEAR::raiseError this method knows three additional parameters: $object, $propery and $operation to make it possibible to always tell where the error occured. You cannot pass the parameters $userinfo and $error_class known from PEAR::raiseError because the three additional parameters are stored in in $userinfo as an associative array and the $class_name is RSError. You would normally call this method just with the arguemnts $object, $property, $operation, $message and $code.

  • return: An instance of the class RSError.
  • see: RSError
  • see: PEAR::raiseError
RSError raiseRSError (String $object, String $property, String $operation, [mixed $message = null], [int $code = null], [int $mode = null], [mixed $options = null], [bool $skipmsg = false])
  • String $object: The name of the object to which the error is related.
  • String $property: The name of the property to which the error is related.
  • String $operation: The name of the operation to which the error is related.
  • mixed $message: A text error message or a PEAR error object.
  • int $code: A numeric error code.
  • int $mode: One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or PEAR_ERROR_CALLBACK.
  • mixed $options: If $mode is PEAR_ERROR_TRIGGER, this parameter specifies the PHP-internal error level (one of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). If $mode is PEAR_ERROR_CALLBACK, this parameter specifies the callback function or method. In other error modes this parameter is ignored.
  • bool $skipmsg: If true, PEAR::raiseError will only pass error codes, the error message parameter will be dropped.
reportError (line 149)

Report the occurence of an error.

This method is called by onFatalError and onPermissionDenied. If you want to do this method anything inherit from RSErrorManager and overwrite this method.

void reportError (PEAR_Error $pearError)
  • PEAR_Error $pearError
reset (line 161)

Removes all errors from the error stack and sets a new default operation.

void reset (String $newOperation)
  • String $newOperation: The name of the default operation.

Documentation generated on Mon, 8 Dec 2003 13:13:06 +0100 by phpDocumentor 1.2.3