1Throwable::Error(3) User Contributed Perl Documentation Throwable::Error(3)
2
3
4
6 Throwable::Error - an easy-to-use class for error objects
7
9 version 0.200013
10
12 package MyApp::Error;
13 # NOTE: Moo can also be used here instead of Moose
14 use Moose;
15 extends 'Throwable::Error';
16
17 has execution_phase => (
18 is => 'ro',
19 isa => 'MyApp::Phase',
20 default => 'startup',
21 );
22
23 ...and in your app...
24
25 MyApp::Error->throw("all communications offline");
26
27 # or...
28
29 MyApp::Error->throw({
30 message => "all communications offline",
31 execution_phase => 'shutdown',
32 });
33
35 Throwable::Error is a base class for exceptions that will be thrown to
36 signal errors and abort normal program flow. Throwable::Error is an
37 alternative to Exception::Class, the features of which are largely
38 provided by the Moo object system atop which Throwable::Error is built.
39
40 Throwable::Error performs the Throwable and StackTrace::Auto roles.
41 That means you can call "throw" on it to create and throw an error
42 object in one call, and that every error object will have a stack trace
43 for its creation.
44
46 message
47 This attribute must be defined and must contain a string describing the
48 error condition. This string will be printed at the top of the stack
49 trace when the error is stringified.
50
51 stack_trace
52 This attribute, provided by StackTrace::Auto, will contain a stack
53 trace object guaranteed to respond to the "as_string" method. For more
54 information about the stack trace and associated behavior, consult the
55 StackTrace::Auto docs.
56
58 as_string
59 This method will provide a string representing the error, containing
60 the error's message followed by the its stack trace.
61
63 · Ricardo SIGNES <rjbs@cpan.org>
64
65 · Florian Ragwitz <rafl@debian.org>
66
68 This software is copyright (c) 2015 by Ricardo SIGNES.
69
70 This is free software; you can redistribute it and/or modify it under
71 the same terms as the Perl 5 programming language system itself.
72
73
74
75perl v5.28.0 2015-07-01 Throwable::Error(3)