3 # ABSTRACT: a role for classes that can be thrown
11 has url => (is => 'ro');
15 Redirect->throw({ url => $url });
19 Throwable is a role for classes that are meant to be thrown as exceptions to
20 standard program flow. It is very simple and does only two things: saves any
21 previous value for C<$@> and calls C<die $self>.
23 =attr previous_exception
25 This attribute is created automatically, and stores the value of C<$@> when the
26 Throwable object is created.
30 has 'previous_exception' => (
34 return unless defined $@ and (ref $@ or length $@);
41 Something::Throwable->throw({ attr => $value });
43 This method will call new, passing all arguments along to new, and will then
44 use the created object as the only argument to C<die>.
46 If called on an object that does Throwable, the object will be rethrown.
54 confess "throw called on Throwable object with arguments" if @_;
58 my $throwable = $inv->new(@_);