1Dancer::Exception::BaseU(s3e)r Contributed Perl DocumentaDtainocner::Exception::Base(3)
2
3
4

NAME

6       Dancer::Exception::Base - the base class of all Dancer exceptions
7

VERSION

9       version 1.3513
10

DESCRIPTION

12       Dancer::Exception::Base is the base class of all Dancer exception. All
13       core exceptions, and all custom exception registered using
14       "Dancer::Exception::register_exception" inherits of
15       "Dancer::Exception::Base".
16

METHODS

18   throw
19       Throws an exception. It's what "raise" (from Dancer::Exception) uses.
20       Any arguments is set as raising parameters. You should not use this
21       method directly, but instead, use "raise" from Dancer::Exception.
22
23       Warning, if you want to rethrow an exception, use "rethrow".
24
25   rethrow
26       Re-throw the exception, without touching its parameters. Useful if
27       you've caught and exception but don't want to handle it, and want to
28       rethrow it.
29
30         try { ... }
31         catch {
32           my ($e) = @_;
33           $e->does('InvalidLogin')
34             or $e->rethrow;
35           ...
36         };
37
38   does
39       Given an exception type, returns true if the exception is of the same
40       type.
41
42         try { raise InvalidLogin => 'foo'; }
43         catch {
44           my ($e) = @_;
45           $e->does('InvalidLogin') # true
46           ...
47         };
48
49       It can receive more than one type, useful for composed exception, or
50       checking multiple types at once. "does" performs a logical OR between
51       them:
52
53         try { raise InvalidPassword => 'foo'; }
54         catch {
55           my ($e) = @_;
56           $e->does('InvalidLogin', 'InvalidPassword') # true
57           ...
58         };
59
60   get_composition
61       Returns the composed types of an exception. As every exception inherits
62       of Dancer::Exception::Base, the returned list contains at least 'Base',
63       and the exception class name.
64
65       Warning, the result is a list, so you should call this method in list
66       context.
67
68         try { raise InvalidPassword => 'foo'; }
69         catch {
70           my ($e) = @_;
71           my @list = $e->get_composition()
72           # @list contains ( 'InvalidPassword', 'Base', ... )
73         };
74
75   message
76       Computes and returns the message associated to the exception. It'll
77       apply the parameters that were set at throw time to the message pattern
78       of the exception.
79

STRINGIFICATION

81   string overloading
82       All Dancer exceptions properly stringify. When evaluated to a string,
83       they return their message, concatenated with their stack trace (see
84       below).
85
86   cmp overloading
87       The "cmp" operator is also overloaded, thus all the string operations
88       can be done on Dancer's exceptions, as they will all be based on the
89       overloaded "cmp" operator. Dancer exceptions will be compared without
90       their stacktraces.
91

STACKTRACE

93       Similarly to Carp, Dancer exceptions stringification appends a string
94       stacktrace to the exception message.
95
96       The stacktrace can be a short one, or a long one. Actually the
97       implementation internally uses Carp.
98
99       To enable long stack trace (for debugging purpose), you can use the
100       global variable "Dancer::Exception::Verbose" (see below).
101
102       The short and long stacktrace snippets are stored within
103       "$self-"{_shortmess}> and "$self-"{_longmess}>. Don't touch them or
104       rely on them, they are internals, and will change soon.
105

GLOBAL VARIABLE

107   $Dancer::Exception::Verbose
108       When set to 1, exceptions will stringify with a long stack trace. This
109       variable is similar to $Carp::Verbose. I recommend you use it like
110       that:
111
112         local $Dancer::Exception::Verbose;
113         $Dancer::Exception::Verbose = 1;
114
115       All the Carp global variables can also be used to alter the stacktrace
116       generation.
117

AUTHOR

119       Dancer Core Developers
120
122       This software is copyright (c) 2010 by Alexis Sukrieh.
123
124       This is free software; you can redistribute it and/or modify it under
125       the same terms as the Perl 5 programming language system itself.
126
127
128
129perl v5.34.0                      2021-07-22        Dancer::Exception::Base(3)
Impressum