1 package Catalyst::Exception::Basic;
3 use MooseX::Role::WithOverloading;
5 use namespace::clean -except => 'meta';
7 with 'Catalyst::Exception::Interface';
12 default => sub { $! || '' },
17 return $self->message;
20 around BUILDARGS => sub {
21 my ($next, $class, @args) = @_;
22 if (@args == 1 && !ref $args[0]) {
23 @args = (message => $args[0]);
26 my $args = $class->$next(@args);
27 $args->{message} ||= $args->{error}
28 if exists $args->{error};
35 my $error = $class->new(@_);
36 local $Carp::CarpLevel = 1;
49 Catalyst::Exception::Basic - Basic Catalyst Exception Role
53 package My::Exception;
55 use namespace::clean -except => 'meta';
57 with 'Catalyst::Exception::Basic';
60 My::Exception->throw( qq/Fatal exception/ );
62 See also L<Catalyst> and L<Catalyst::Exception>.
66 This is the basic Catalyst Exception role which implements all of
67 L<Catalyst::Exception::Interface>.
73 Holds the exception message.
79 Stringifies the exception's message attribute.
80 Called when the object is stringified by overloading.
82 =head2 throw( $message )
84 =head2 throw( message => $message )
86 =head2 throw( error => $error )
88 Throws a fatal exception.
90 =head2 rethrow( $exception )
92 Rethrows a caught exception.
100 Catalyst Contributors, see Catalyst.pm
104 This library is free software. You can redistribute it and/or modify
105 it under the same terms as Perl itself.