NAME

PApp::Exception - exception handling for PApp


SYNOPSIS

 use PApp::Exception;
 # to be written


DESCRIPTION

# to be written

local $SIG{__DIE__} = \&PApp::Exception::diehandler
_diehandler is a function suitable to be put into $SIG{__DIE__} (e.g. inside an eval). The advantage in using this function is that you get a useful backtrace on an error (among some other information). It should be compatible with any use of eval but might slow down evals that make heavy use of exceptions (but these are slow anyway).

Example:

 eval {
    local $SIG{__DIE__} = \&PApp::Exception::diehandler;
    ...
 };

$errobj = new PApp::Exception param => value..
Create and return a new exception object. The object is overloaded, stringification will call as_string.
 title      exception page title (default "PApp:Exception")
 body       the exception page body
 category   the error category
 error      the error message or error object
 info       additional info (arrayref)
 backtrace  optional backtrace info
 compatible if set, stringification will only return this field

When called on an existing object, a clone of that exception object is created and the information is extended (backtrace is being ignored, title, info and error are extended).

$errobj->throw
Throw the exception.

$errobj->as_string
Return the full exception information as simple text string.

$errobj->as_html
Return the full exception information as a fully formatted html page.

fancydie $category, $error, [param => value...]
Aborts the current page and displays a fancy error box, complete with backtrace. $error should be a short error message, while $additional_info can be a multi-line description of the problem.

The rest of the function call consists of named arguments that are transparently passed to the PApp::Exception::new constructor (see above), with the exception of:

 skipcallers  the number of caller levels to skip in the backtrace

fancywarn <same arguments as fancydie>
Similar to fancydie, but warns only. (not exported by default).

vals = try BLOCK error, args...
eval the given block (using a _diehandler, @_ will contain useless values and the context will always be array context). If no error occurs, return, otherwise execute fancydie with the error message and the rest of the arguments (unless they are catch'ed).

catch BLOCK args...
Not yet implemented. If used as an argument to try, execute the block when an error occurs.

$exc->errorpage
This method is being called by the PApp runtime whenever there is no handler for it. It should (depending on the $PApp::onerr variable and others!) display an error page for the user. Better overwrite the following methods, not this one.

$exc->ep_save
$html = $exc->ep_fullinfo
$html = $exc->ep_shortinfo
$html = $exc->ep_login
$html = $exc->ep_wrap(...)


SEE ALSO

the PApp manpage.


AUTHOR

 Marc Lehmann <pcg@goof.com>
 http://www.goof.com/pcg/marc/