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.102080
10
12 package MyApp::Error;
13 use Moose;
14 extends 'Throwable::Error';
15
16 has execution_phase => (
17 is => 'ro',
18 isa => 'MyApp::Phase',
19 default => 'startup',
20 );
21
22 ...and in your app...
23
24 MyApp::Error->throw("all communications offline");
25
26 # or...
27
28 MyApp::Error->throw({
29 message => "all communications offline",
30 phase => 'shutdown',
31 });
32
34 Throwable::Error is a base class for exceptions that will be thrown to
35 signal errors and abort normal program flow. Throwable::Error is an
36 alternative to Exception::Class, the features of which are largely
37 provided by the Moose object system atop which Throwable::Error is
38 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 n 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) 2010 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.12.1 2010-07-27 Throwable::Error(3)