<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Catalyst::Exception::Basic;

use Moose::Role;
use if !eval { require Moose; Moose-&gt;VERSION('2.1300') },
    'MooseX::Role::WithOverloading';
use Carp;
use namespace::clean -except =&gt; 'meta';

with 'Catalyst::Exception::Interface';

has message =&gt; (
    is      =&gt; 'ro',
    isa     =&gt; 'Str',
    default =&gt; sub { $! || '' },
);

sub as_string {
    my ($self) = @_;
    return $self-&gt;message;
}

around BUILDARGS =&gt; sub {
    my ($next, $class, @args) = @_;
    if (@args == 1 &amp;&amp; !ref $args[0]) {
        @args = (message =&gt; $args[0]);
    }

    my $args = $class-&gt;$next(@args);
    $args-&gt;{message} ||= $args-&gt;{error}
        if exists $args-&gt;{error};

    return $args;
};

sub throw {
    my $class = shift;
    my $error = $class-&gt;new(@_);
    local $Carp::CarpLevel = 1;
    croak $error;
}

sub rethrow {
    my ($self) = @_;
    croak $self;
}

1;

=head1 NAME

Catalyst::Exception::Basic - Basic Catalyst Exception Role

=head1 SYNOPSIS

   package My::Exception;
   use Moose;
   use namespace::clean -except =&gt; 'meta';

   with 'Catalyst::Exception::Basic';

   # Elsewhere..
   My::Exception-&gt;throw( qq/Fatal exception/ );

See also L&lt;Catalyst&gt; and L&lt;Catalyst::Exception&gt;.

=head1 DESCRIPTION

This is the basic Catalyst Exception role which implements all of
L&lt;Catalyst::Exception::Interface&gt;.

=head1 ATTRIBUTES

=head2 message

Holds the exception message.

=head1 METHODS

=head2 as_string

Stringifies the exception's message attribute.
Called when the object is stringified by overloading.

=head2 throw( $message )

=head2 throw( message =&gt; $message )

=head2 throw( error =&gt; $error )

Throws a fatal exception.

=head2 rethrow( $exception )

Rethrows a caught exception.

=head2 meta

Provided by Moose

=head1 AUTHORS

Catalyst Contributors, see Catalyst.pm

=head1 COPYRIGHT

This library is free software. You can redistribute it and/or modify
it under the same terms as Perl itself.

=cut
</pre></body></html>