1Throwable(3) User Contributed Perl Documentation Throwable(3)
2
3
4
6 Throwable - a role for classes that can be thrown
7
9 version 0.200013
10
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
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
32 previous_exception
33 This attribute is created automatically, and stores the value of $@
34 when the Throwable object is created. This is done on a best effort
35 basis. $@ is subject to lots of spooky action-at-a-distance. For now,
36 there are clearly ways that the previous exception could be lost.
37
39 throw
40 Something::Throwable->throw({ attr => $value });
41
42 This method will call new, passing all arguments along to new, and will
43 then use the created object as the only argument to "die".
44
45 If called on an object that does Throwable, the object will be
46 rethrown.
47
49 · Ricardo SIGNES <rjbs@cpan.org>
50
51 · Florian Ragwitz <rafl@debian.org>
52
54 · Arthur Axel 'fREW' Schmidt <frioux@gmail.com>
55
56 · Brian Manning <brian@xaoc.org>
57
58 · Brian Manning <xaoc@cpan.org>
59
60 · Dagfinn Ilmari Mannsåker <ilmari@ilmari.org>
61
62 · Dave Rolsky <autarch@urth.org>
63
64 · David E. Wheeler <david@justatheory.com>
65
66 · Graham Knop <haarg@haarg.org>
67
68 · Jeffrey Ryan Thalhammer <jeff@imaginative-software.com>
69
70 · Justin Hunter <justin.d.hunter@gmail.com>
71
72 · Matt S Trout <mst@shadowcat.co.uk>
73
74 · Olaf Alders <olaf@wundersolutions.com>
75
76 · Toby Inkster <mail@tobyinkster.co.uk>
77
79 This software is copyright (c) 2015 by Ricardo SIGNES.
80
81 This is free software; you can redistribute it and/or modify it under
82 the same terms as the Perl 5 programming language system itself.
83
84
85
86perl v5.30.1 2020-01-30 Throwable(3)