class X::AdHoc
src
class X::AdHoc is Exception { ... }
X::AdHoc is the type into which objects are wrapped if they are
thrown as exceptions, but don't inherit from L<Exception>.
Its benefit over returning non- Exception objects is that it gives
access to all the methods from class L<Exception>, like backtrace
and rethrow .
You can obtain the original object with the payload method.
try {
die [404, 'File not found']; # throw non-exception object
}
say "Got HTTP code ",
$!.payload[0], # 404
" and backtrace ",
$!.backtrace;
Methods
payload
method payload(X::AdHoc:D)
Returns the original object which was passed to die .