Home  Support  API

Exceptionizer Class Reference
[Bootstrap]


Exceptionizer is the signleton that translates the specified errors occured at runtime into exceptions.

Phoebius Framework promotes using exceptions instead of errors to make code more predictible.

Definition at line 25 of file Exceptionizer.class.php.

Inheritance diagram for Exceptionizer:
Inheritance graph

List of all members.

Static Public Member Functions

static getInstance ()
 Gets the instance of singleton class.

Public Member Functions

 dropErrorTypedException ($errorType)
 Drops an exception set to a custom error type so that this error type will now be casted to a default exception class.
 dropErrorTypedExceptions ()
 Drops all exceptinons set to the custom error types so that now all error types covered by a mask will be casted to a default exception class.
 errorHandler ($errno, $errstr, $errfile, $errline)
 Default error handler, that casts covered errors to their appropriate exceptions.
 handleUncovered ()
 Specifies that errors that match the cover mask specified, should be handled by the default error handler.
 register ($coverMask=E_ALL, $supressUncovered, $defaultExceptionName)
 Registers an exceptionizer with the specified parameters that could be changed at runtime.
 setCoverMask ($coverMask=E_ALL)
 Sets the mask to what errors should be translated to exceptions.
 setDefaultException ($exceptionName)
 Sets the default exception name to which the errors should be casted.
 setException ($errorType, $exceptionName)
 Sets the exception to a separate error type to be casted to.
 setUncoveredErrorsIgnorance ($flag=false)
 Specifies what to do with errors that do not match the cover mask.
 supressUncovered ()
 Specifies that errors that do not match the cover mask specified, should be supressed.
 unregister ()
 Unregisters an exceptionizer.

Static Protected Member Functions

static instance ($className)
 Returns the single instance of the singleton (which is created at first request).
static isInstantiated ($className)
 Determines whether the singleton class was instantiated.

Member Function Documentation

Exceptionizer::dropErrorTypedException ( errorType  ) 

Drops an exception set to a custom error type so that this error type will now be casted to a default exception class.

Parameters:
integer $errorTypean separate error type (not a mask!)
Returns:
Exceptionizer itself

Definition at line 144 of file Exceptionizer.class.php.

References Assert::isTrue().

Exceptionizer::dropErrorTypedExceptions (  ) 

Drops all exceptinons set to the custom error types so that now all error types covered by a mask will be casted to a default exception class.

Returns:
Exceptionizer itself

Definition at line 158 of file Exceptionizer.class.php.

Exceptionizer::errorHandler ( errno,
errstr,
errfile,
errline 
)

Default error handler, that casts covered errors to their appropriate exceptions.

Returns:
boolean

Definition at line 243 of file Exceptionizer.class.php.

References TypeUtils::isChild(), Assert::isTrue(), and supressUncovered().

static Exceptionizer::getInstance (  )  [static]

Gets the instance of singleton class.

Returns:
Exceptionizer itself

Definition at line 60 of file Exceptionizer.class.php.

References LazySingleton::instance(), and LazySingleton::isInstantiated().

Referenced by ClassResolver::loadClassFile(), and AllTests::suite().

Exceptionizer::handleUncovered (  ) 

Specifies that errors that match the cover mask specified, should be handled by the default error handler.

Returns:
Exceptionizer itself

Definition at line 219 of file Exceptionizer.class.php.

References setUncoveredErrorsIgnorance().

static LazySingleton::instance ( className  )  [static, protected, inherited]

Returns the single instance of the singleton (which is created at first request).

Parameters:
string classname
Returns:
object

Definition at line 57 of file LazySingleton.class.php.

Referenced by LoggerPool::getInstance(), DummyDialect::getInstance(), DBPool::getInstance(), PathResolver::getInstance(), getInstance(), and Autoloader::getInstance().

static LazySingleton::isInstantiated ( className  )  [static, protected, inherited]

Determines whether the singleton class was instantiated.

Parameters:
string $className classname
Returns:
boolean

Definition at line 47 of file LazySingleton.class.php.

Referenced by getInstance().

Exceptionizer::register ( coverMask = E_ALL,
supressUncovered,
defaultExceptionName 
)

Registers an exceptionizer with the specified parameters that could be changed at runtime.

Parameters:
integer $coverMask integer mask to specify what errors should be translated to exceptions. E.g., if you specify E_WARNING | E_NOTICE as the cover mask, E_NOTICE and E_WARNING errors would be translated to exceptions, but E_ERROR is not. Default is E_ALL.
boolean $supressUncovered specifies what to do with errors that do not match the cover mask. If you wish to supress them and let the default handler to process those errors than you can set this argument to false.
string $defaultExceptionName name of the exception to be thrown when translatable error occurs. Default is Exception
Returns:
Exceptionizer itself

Definition at line 82 of file Exceptionizer.class.php.

References setCoverMask(), setDefaultException(), and setUncoveredErrorsIgnorance().

Exceptionizer::setCoverMask ( coverMask = E_ALL  ) 

Sets the mask to what errors should be translated to exceptions.

E.g., if you specify E_WARNING | E_NOTICE as the cover mask, E_NOTICE and E_WARNING errors would be translated to exceptions, but E_ERROR is not.

Parameters:
integer $coverMask integer mask to specify what errors should be translated to exceptions. E.g., if you specify E_WARNING | E_NOTICE as the cover mask, E_NOTICE and E_WARNING errors would be translated to exceptions, but E_ERROR is not. Default is E_ALL.
Returns:
Exceptionizer itself

Definition at line 175 of file Exceptionizer.class.php.

References Assert::isNumeric(), and Assert::isTrue().

Referenced by register().

Exceptionizer::setDefaultException ( exceptionName  ) 

Sets the default exception name to which the errors should be casted.

Parameters:
string $exceptionName name of the exception class that implements IErrorExceptionFactory
Returns:
Exceptionizer itself

Definition at line 103 of file Exceptionizer.class.php.

References TypeUtils::isChild(), and Assert::isTrue().

Referenced by register(), and setException().

Exceptionizer::setException ( errorType,
exceptionName 
)

Sets the exception to a separate error type to be casted to.

I.e. you can cast all errors to the ExecutionContextException and E_USER_ERROR to CompilationContextException

Parameters:
integer $errorTypean separate error type (not a mask!)
string $exceptionName name of an exception class that implements IErrorExceptionFactory
Returns:
Exceptionizer itself

Definition at line 121 of file Exceptionizer.class.php.

References TypeUtils::isChild(), Assert::isTrue(), and setDefaultException().

Exceptionizer::setUncoveredErrorsIgnorance ( flag = false  ) 

Specifies what to do with errors that do not match the cover mask.

If you wish to supress them and let the default handler to process those errors than you can set this argument to false.

Parameters:
boolean $supressUncovered specifies what to do with errors that do not match the cover mask. If you wish to supress them and let the default handler to process those errors than you can set this argument to false.
Returns:
Exceptionizer itself

Definition at line 194 of file Exceptionizer.class.php.

References Assert::isBoolean(), and supressUncovered().

Referenced by handleUncovered(), register(), and supressUncovered().

Exceptionizer::supressUncovered (  ) 

Specifies that errors that do not match the cover mask specified, should be supressed.

Returns:
Exceptionizer itself

Definition at line 207 of file Exceptionizer.class.php.

References setUncoveredErrorsIgnorance().

Referenced by errorHandler(), and setUncoveredErrorsIgnorance().

Exceptionizer::unregister (  ) 

Unregisters an exceptionizer.

Returns:
Exceptionizer

Definition at line 230 of file Exceptionizer.class.php.

References Assert::isTrue().


The documentation for this class was generated from the following file: