.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Dancer::Exception::Base 3pm" .TH Dancer::Exception::Base 3pm "2018-12-23" "perl v5.28.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Dancer::Exception::Base \- the base class of all Dancer exceptions .SH "VERSION" .IX Header "VERSION" version 1.3500 .SH "DESCRIPTION" .IX Header "DESCRIPTION" Dancer::Exception::Base is the base class of all Dancer exception. All core exceptions, and all custom exception registered using \&\f(CW\*(C`Dancer::Exception::register_exception\*(C'\fR inherits of \&\f(CW\*(C`Dancer::Exception::Base\*(C'\fR. .SH "METHODS" .IX Header "METHODS" .SS "throw" .IX Subsection "throw" Throws an exception. It's what \f(CW\*(C`raise\*(C'\fR (from Dancer::Exception) uses. Any arguments is set as raising parameters. You should not use this method directly, but instead, use \f(CW\*(C`raise\*(C'\fR from Dancer::Exception. .PP \&\fBWarning\fR, if you want to rethrow an exception, use \f(CW\*(C`rethrow\*(C'\fR. .SS "rethrow" .IX Subsection "rethrow" Re-throw the exception, without touching its parameters. Useful if you've caught and exception but don't want to handle it, and want to rethrow it. .PP .Vb 7 \& try { ... } \& catch { \& my ($e) = @_; \& $e\->does(\*(AqInvalidLogin\*(Aq) \& or $e\->rethrow; \& ... \& }; .Ve .SS "does" .IX Subsection "does" Given an exception type, returns true if the exception is of the same type. .PP .Vb 6 \& try { raise InvalidLogin => \*(Aqfoo\*(Aq; } \& catch { \& my ($e) = @_; \& $e\->does(\*(AqInvalidLogin\*(Aq) # true \& ... \& }; .Ve .PP It can receive more than one type, useful for composed exception, or checking multiple types at once. \f(CW\*(C`does\*(C'\fR performs a logical \s-1OR\s0 between them: .PP .Vb 6 \& try { raise InvalidPassword => \*(Aqfoo\*(Aq; } \& catch { \& my ($e) = @_; \& $e\->does(\*(AqInvalidLogin\*(Aq, \*(AqInvalidPassword\*(Aq) # true \& ... \& }; .Ve .SS "get_composition" .IX Subsection "get_composition" Returns the composed types of an exception. As every exception inherits of Dancer::Exception::Base, the returned list contains at least 'Base', and the exception class name. .PP \&\fBWarning\fR, the result is a list, so you should call this method in list context. .PP .Vb 6 \& try { raise InvalidPassword => \*(Aqfoo\*(Aq; } \& catch { \& my ($e) = @_; \& my @list = $e\->get_composition() \& # @list contains ( \*(AqInvalidPassword\*(Aq, \*(AqBase\*(Aq, ... ) \& }; .Ve .SS "message" .IX Subsection "message" Computes and returns the message associated to the exception. It'll apply the parameters that were set at throw time to the message pattern of the exception. .SH "STRINGIFICATION" .IX Header "STRINGIFICATION" .SS "string overloading" .IX Subsection "string overloading" All Dancer exceptions properly stringify. When evaluated to a string, they return their message, concatenated with their stack trace (see below). .SS "cmp overloading" .IX Subsection "cmp overloading" The \f(CW\*(C`cmp\*(C'\fR operator is also overloaded, thus all the string operations can be done on Dancer's exceptions, as they will all be based on the overloaded \f(CW\*(C`cmp\*(C'\fR operator. Dancer exceptions will be compared \fBwithout\fR their stacktraces. .SH "STACKTRACE" .IX Header "STACKTRACE" Similarly to Carp, Dancer exceptions stringification appends a string stacktrace to the exception message. .PP The stacktrace can be a short one, or a long one. Actually the implementation internally uses Carp. .PP To enable long stack trace (for debugging purpose), you can use the global variable \f(CW\*(C`Dancer::Exception::Verbose\*(C'\fR (see below). .PP The short and long stacktrace snippets are stored within \f(CW\*(C`$self\-\*(C'\fR{_shortmess}> and \f(CW\*(C`$self\-\*(C'\fR{_longmess}>. Don't touch them or rely on them, they are internals, and will change soon. .SH "GLOBAL VARIABLE" .IX Header "GLOBAL VARIABLE" .ie n .SS "$Dancer::Exception::Verbose" .el .SS "\f(CW$Dancer::Exception::Verbose\fP" .IX Subsection "$Dancer::Exception::Verbose" When set to 1, exceptions will stringify with a long stack trace. This variable is similar to \f(CW$Carp::Verbose\fR. I recommend you use it like that: .PP .Vb 2 \& local $Dancer::Exception::Verbose; \& $Dancer::Exception::Verbose = 1; .Ve .PP All the Carp global variables can also be used to alter the stacktrace generation. .SH "AUTHOR" .IX Header "AUTHOR" Dancer Core Developers .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2010 by Alexis Sukrieh. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.