System
[ class tree: System ] [ index: System ] [ all elements ]

Class: TErrorHandler

Source Location: /TErrorHandler.php

Class Overview


TErrorHandler class

Class Details

[line 43]
TErrorHandler class

TErrorHandler dispatchs error messages to different error pages. The error pages responsible for different error code can be configured in the application specification using the following format,

  1. <error class="TErrorHandler">
  2. <when error="SiteOff" page="SiteOffPage" />
  3. <when error="Unauthorized" page="Error401Page" />
  4. <when error="Forbidden" page="Error403Page" />
  5. <when error="PageNotFound" page="Error404Page" />
  6. <when error="InternalError" page="Error500Page" />
  7. <otherwise page="xxx" />
  8. </error>
where each page attribute refers to a page name.

Namespace: System




version:  v1.0, last update on 2004/08/13 21:44:52
author:  Qiang Xue <qiang.xue@gmail.com>


[ Top ]

Variables

Constants

Methods



Class Variables

$defaultPage = ''

[line 63]

default page to handle unrecognized error



access:  protected

Type:   string


[ Top ]

$errorCode = ''

[line 73]

error code



access:  protected

Type:   string


[ Top ]

$errorMessage = ''

[line 68]

error message



access:  protected

Type:   string


[ Top ]

$errorPages = array()

[line 58]

list of error handling pages



access:  protected

Type:   array


[ Top ]



Class Methods


constructor __construct [line 80]

TErrorHandler __construct( mixed $config)

Constructor.

This method reads the configuration given by the application specification.




Parameters:

mixed   $config   the configuration

[ Top ]

method getErrorCode [line 154]

string getErrorCode( )



return:  the error code
access:  public


[ Top ]

method getErrorMessage [line 162]

string getErrorMessage( )



return:  the error message
access:  public


[ Top ]

method handleError [line 100]

void handleError( string $code, [string|Exception $e = ''])

Dispatches the error handling to a page.

The error page will be executed and the rendering result be displayed. If the error is not handled by a page, the method will display the error directly based on the application state (debug or not). This method always terminates the execution of the current application.




access:  public


Parameters:

string   $code   error code
string|Exception   $e   error message or exception

[ Top ]


Class Constants

CASE_FORBIDDEN = 'Forbidden'

[line 51]


[ Top ]

CASE_INTERNALERROR = 'InternalError'

[line 52]


[ Top ]

CASE_PAGENOTFOUND = 'PageNotFound'

[line 49]


[ Top ]

CASE_SITEOFF = 'SiteOff'

[line 48]

some predefined error codes.


[ Top ]

CASE_UNAUTHORIZED = 'Unauthorized'

[line 50]


[ Top ]



© 2004-2005 PRADO Software Group. All Rights Reserved.