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 1.001
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 This library should run on perls released even a long time ago. It
47 should work on any version of perl released in the last five years.
48
49 Although it may work on older versions of perl, no guarantee is made
50 that the minimum required version will not be increased. The version
51 may be increased for any reason, and there is no promise that patches
52 will be accepted to lower the minimum required perl.
53
55 message
56 This attribute must be defined and must contain a string describing the
57 error condition. This string will be printed at the top of the stack
58 trace when the error is stringified.
59
60 stack_trace
61 This attribute, provided by StackTrace::Auto, will contain a stack
62 trace object guaranteed to respond to the "as_string" method. For more
63 information about the stack trace and associated behavior, consult the
64 StackTrace::Auto docs.
65
67 as_string
68 This method will provide a string representing the error, containing
69 the error's message followed by the its stack trace.
70
72 • Ricardo SIGNES <cpan@semiotic.systems>
73
74 • Florian Ragwitz <rafl@debian.org>
75
77 This software is copyright (c) 2022 by Ricardo SIGNES.
78
79 This is free software; you can redistribute it and/or modify it under
80 the same terms as the Perl 5 programming language system itself.
81
82
83
84perl v5.36.0 2023-01-20 Throwable::Error(3)