1 package Catalyst::Exception::Basic;
4 use if !eval { require Moose; Moose->VERSION('2.1300') },
5 'MooseX::Role::WithOverloading';
7 use namespace::clean -except => 'meta';
9 with 'Catalyst::Exception::Interface';
14 default => sub { $! || '' },
19 return $self->message;
22 around BUILDARGS => sub {
23 my ($next, $class, @args) = @_;
24 if (@args == 1 && !ref $args[0]) {
25 @args = (message => $args[0]);
28 my $args = $class->$next(@args);
29 $args->{message} ||= $args->{error}
30 if exists $args->{error};
37 my $error = $class->new(@_);
38 local $Carp::CarpLevel = 1;
51 Catalyst::Exception::Basic - Basic Catalyst Exception Role
55 package My::Exception;
57 use namespace::clean -except => 'meta';
59 with 'Catalyst::Exception::Basic';
62 My::Exception->throw( qq/Fatal exception/ );
64 See also L<Catalyst> and L<Catalyst::Exception>.
68 This is the basic Catalyst Exception role which implements all of
69 L<Catalyst::Exception::Interface>.
75 Holds the exception message.
81 Stringifies the exception's message attribute.
82 Called when the object is stringified by overloading.
84 =head2 throw( $message )
86 =head2 throw( message => $message )
88 =head2 throw( error => $error )
90 Throws a fatal exception.
92 =head2 rethrow( $exception )
94 Rethrows a caught exception.
102 Catalyst Contributors, see Catalyst.pm
106 This library is free software. You can redistribute it and/or modify
107 it under the same terms as Perl itself.