1Throwable(3)          User Contributed Perl Documentation         Throwable(3)
2
3
4

NAME

6       Throwable - a role for classes that can be thrown
7

VERSION

9       version 1.000
10

SYNOPSIS

12         package Redirect;
13         # NOTE: Moo can also be used here instead of Moose
14         use Moose;
15         with 'Throwable';
16
17         has url => (is => 'ro');
18
19       ...then later...
20
21         Redirect->throw({ url => $url });
22

DESCRIPTION

24       Throwable is a role for classes that are meant to be thrown as
25       exceptions to standard program flow.  It is very simple and does only
26       two things: saves any previous value for $@ and calls "die $self".
27
28       Throwable is implemented with Moo, so you can stick to Moo or use
29       Moose, as you prefer.
30

PERL VERSION SUPPORT

32       This module has a long-term perl support period.  That means it will
33       not require a version of perl released fewer than five years ago.
34
35       Although it may work on older versions of perl, no guarantee is made
36       that the minimum required version will not be increased.  The version
37       may be increased for any reason, and there is no promise that patches
38       will be accepted to lower the minimum required perl.
39

ATTRIBUTES

41   previous_exception
42       This attribute is created automatically, and stores the value of $@
43       when the Throwable object is created.  This is done on a best effort
44       basis.  $@ is subject to lots of spooky action-at-a-distance.  For now,
45       there are clearly ways that the previous exception could be lost.
46

METHODS

48   throw
49         Something::Throwable->throw({ attr => $value });
50
51       This method will call new, passing all arguments along to new, and will
52       then use the created object as the only argument to "die".
53
54       If called on an object that does Throwable, the object will be
55       rethrown.
56
57   new_with_previous
58         die Something::Throwable->new_with_previous({ attr => $value });
59
60       Constructs an exception object and return it, while trying to mae sure
61       that any values in $@ are safely stored in "previous_exception" without
62       being stomped by evals in the construction process.
63
64       This is more reliable than calling "new" directly, but doesn't include
65       the forced "die" in "throw".
66

AUTHORS

68       •   Ricardo SIGNES <rjbs@semiotic.systems>
69
70       •   Florian Ragwitz <rafl@debian.org>
71

CONTRIBUTORS

73       •   Arthur Axel 'fREW' Schmidt <frioux@gmail.com>
74
75       •   Brian Manning <brian@xaoc.org>
76
77       •   Brian Manning <xaoc@cpan.org>
78
79       •   Christian Walde <walde.christian@googlemail.com>
80
81       •   Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
82
83       •   Dave Rolsky <autarch@urth.org>
84
85       •   David E. Wheeler <david@justatheory.com>
86
87       •   Graham Knop <haarg@haarg.org>
88
89       •   Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
90
91       •   Justin Hunter <justin.d.hunter@gmail.com>
92
93       •   Matt S Trout <mst@shadowcat.co.uk>
94
95       •   Olaf Alders <olaf@wundersolutions.com>
96
97       •   Toby Inkster <mail@tobyinkster.co.uk>
98
100       This software is copyright (c) 2021 by Ricardo SIGNES.
101
102       This is free software; you can redistribute it and/or modify it under
103       the same terms as the Perl 5 programming language system itself.
104
105
106
107perl v5.34.0                      2022-01-21                      Throwable(3)
Impressum