| 1 | package Catalyst::Exception::Basic; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 180 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 180 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 180 | ▶ | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 180 | with 'Catalyst::Exception::Interface'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | has message => ( | ||||||||||||||||||||||||||||
| 10 | is => 'ro', | ||||||||||||||||||||||||||||
| 11 | isa => 'Str', | ||||||||||||||||||||||||||||
| 12 | 0 | ▶ | default => sub { $! || '' }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | 180 | ); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 126 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 16 | 126 | my ($self) = @_; | |||||||||||||||||||||||||||
| 17 | 126 | return $self->message; | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 363 | ▶ | around BUILDARGS => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=5 SCAR=17.5
| |||||||||||||||||||||||||||||
| 21 | 363 | my ($next, $class, @args) = @_; | |||||||||||||||||||||||||||
| 22 | 363 | ▶ | if (@args == 1 && !ref $args[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@args == 1 and not ref $args[0]
MC/DC50%1/2
@args == 1 and not ref $args[0]
@args == 1
not ref $args[0]
Truth table66%2/3
A and not(B)
A= @args == 1B= not ref $args[0]
| |||||||||||||||||||||||||||||
| 23 | 8 | @args = (message => $args[0]); | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 363 | my $args = $class->$next(@args); | |||||||||||||||||||||||||||
| 27 | $args->{message} ||= $args->{error} | ||||||||||||||||||||||||||||
| 28 | 363 | ▶ | if exists $args->{error}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args->{"message"} ||= $args->{"error"}
MC/DC0%0/2
$args->{"message"} ||= $args->{"error"}
$args->{"message"}
$args->{"error"}
Truth table0%0/3
A ||= B
A= $args->{"message"}B= $args->{"error"}
| |||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 363 | return $args; | |||||||||||||||||||||||||||
| 31 | 180 | }; | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 35 | ▶ | sub throw { | ||||||||||||||||||||||||||
|
Subroutine
throw: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 34 | 35 | my $class = shift; | |||||||||||||||||||||||||||
| 35 | 35 | my $error = $class->new(@_); | |||||||||||||||||||||||||||
| 36 | 35 | local $Carp::CarpLevel = 1; | |||||||||||||||||||||||||||
| 37 | 35 | croak $error; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 68 | ▶ | sub rethrow { | ||||||||||||||||||||||||||
|
Subroutine
rethrow: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 41 | 68 | my ($self) = @_; | |||||||||||||||||||||||||||
| 42 | 68 | croak $self; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 180 | 1; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | =head1 NAME | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | Catalyst::Exception::Basic - Basic Catalyst Exception Role | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | package My::Exception; | ||||||||||||||||||||||||||||
| 54 | use Moose; | ||||||||||||||||||||||||||||
| 55 | use namespace::clean -except => 'meta'; | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | with 'Catalyst::Exception::Basic'; | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | # Elsewhere.. | ||||||||||||||||||||||||||||
| 60 | My::Exception->throw( qq/Fatal exception/ ); | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | See also L<Catalyst> and L<Catalyst::Exception>. | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | This is the basic Catalyst Exception role which implements all of | ||||||||||||||||||||||||||||
| 67 | L<Catalyst::Exception::Interface>. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =head2 message | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Holds the exception message. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | =head1 METHODS | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | =head2 as_string | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | Stringifies the exception's message attribute. | ||||||||||||||||||||||||||||
| 80 | Called when the object is stringified by overloading. | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | =head2 throw( $message ) | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | =head2 throw( message => $message ) | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =head2 throw( error => $error ) | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | Throws a fatal exception. | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =head2 rethrow( $exception ) | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Rethrows a caught exception. | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head2 meta | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | Provided by Moose | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =head1 AUTHORS | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Catalyst Contributors, see Catalyst.pm | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | This library is free software. You can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 105 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | =cut | ||||||||||||||||||||||||||||