| 1 | package MooseX::Error::Exception::Class; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use 5.008001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 2 | our $VERSION = '0.099'; | |||||||||
| 8 | 2 | $VERSION = eval { return $VERSION }; | |||||||||
| 9 | |||||||||||
| 10 | 2 | ▶ | use Exception::Class 1.29 ( | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | 'Exception::Moose' => { | |||||||||
| 12 | 'description' => 'Error', | ||||||||||
| 13 | 'fields' => [qw(message longmess)], | ||||||||||
| 14 | }, | ||||||||||
| 15 | 'Exception::Moose::Validation' => { | ||||||||||
| 16 | 'description' => 'Validation error', | ||||||||||
| 17 | 'isa' => 'Exception::Moose', | ||||||||||
| 18 | 'fields' => [qw(attribute type value message longmess)], | ||||||||||
| 19 | }, | ||||||||||
| 20 | 2 | ); | |||||||||
| 21 | |||||||||||
| 22 | 0 | ▶ | sub Exception::Moose::full_message { ## no critic 'Capitalization' | ||||||||
|
Subroutine
full_message: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 23 | 0 | my $self = shift; | |||||||||
| 24 | |||||||||||
| 25 | 0 | my $string = | |||||||||
| 26 | $self->description() . ': ' | ||||||||||
| 27 | . $self->message() . "\n" | ||||||||||
| 28 | . ' Time error caught: ' | ||||||||||
| 29 | . localtime() . "\n"; | ||||||||||
| 30 | |||||||||||
| 31 | # Add trace to it if asked for. | ||||||||||
| 32 | 0 | ▶ | if ( ( $self->longmess() ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 33 | 0 | $string .= "\n" . $self->trace() . "\n"; | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 0 | return $string; | |||||||||
| 37 | } ## end sub Exception::Moose::full_message | ||||||||||
| 38 | |||||||||||
| 39 | sub Exception::Moose::Validation::full_message | ||||||||||
| 40 | 0 | ▶ | { ## no critic 'Capitalization' | ||||||||
|
Subroutine
full_message: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||
| 41 | 0 | my $self = shift; | |||||||||
| 42 | |||||||||||
| 43 | 0 | my $string = | |||||||||
| 44 | $self->description() | ||||||||||
| 45 | . qq{:\n '} | ||||||||||
| 46 | . $self->attribute() | ||||||||||
| 47 | . q{' not } | ||||||||||
| 48 | . $self->type() | ||||||||||
| 49 | . q{ (value passed in: '} | ||||||||||
| 50 | . $self->value | ||||||||||
| 51 | . qq{')\n} | ||||||||||
| 52 | . ' Time error caught: ' | ||||||||||
| 53 | . localtime() . "\n"; | ||||||||||
| 54 | |||||||||||
| 55 | # Add trace to it if asked for. | ||||||||||
| 56 | 0 | ▶ | if ( ( $self->longmess() ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 57 | 0 | $string .= "\n" . $self->trace() . "\n"; | |||||||||
| 58 | } | ||||||||||
| 59 | |||||||||||
| 60 | 0 | return $string; | |||||||||
| 61 | } ## end sub Exception::Moose::Validation::full_message | ||||||||||
| 62 | |||||||||||
| 63 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 64 | 0 | my ( $self, @args ) = @_; | |||||||||
| 65 | 0 | return $self->_create_error(@args); | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 0 | ▶ | sub _create_error { | ||||||||
|
Subroutine
_create_error: not called CC=5 SCAR=34.0
| |||||||||||
| 69 | 0 | my ( $self, %args ) = @_; | |||||||||
| 70 | |||||||||||
| 71 | 0 | ▶ | my @args = exists $args{message} ? $args{message} : (); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 72 | 0 | my $info = join q{}, @args; | |||||||||
| 73 | |||||||||||
| 74 | 0 | ▶ | if ($info =~ m{\A | ||||||||
|
Branch: 1 branch
| |||||||||||
| 75 | Attribute [ ] \((.*)\) # $1 = attribute name | ||||||||||
| 76 | [ ] does [ ] not [ ] pass [ ] the | ||||||||||
| 77 | [ ] type [ ] constraint [ ] because: | ||||||||||
| 78 | [ ] Validation [ ] failed [ ] for [ ] '(.*)' # $2 = type | ||||||||||
| 79 | [ ] failed [ ] with [ ] value [ ] (.*) # $3 = bad value | ||||||||||
| 80 | \z}msx | ||||||||||
| 81 | ) | ||||||||||
| 82 | { | ||||||||||
| 83 | 0 | my ( $attr_name, $attr_type, $value ) = ( $1, $2, $3 ); | |||||||||
| 84 | |||||||||||
| 85 | Exception::Moose::Validation->throw( | ||||||||||
| 86 | message => $info, | ||||||||||
| 87 | attribute => $attr_name, | ||||||||||
| 88 | type => $attr_type, | ||||||||||
| 89 | value => $value, | ||||||||||
| 90 | 0 | ▶ | longmess => exists $args{longmess} ? !!$args{longmess} : 1, | ||||||||
|
Branch: 1 branch
| |||||||||||
| 91 | ignore_class => | ||||||||||
| 92 | [qw(MooseX::Error::Exception::Class Moose::Meta::Class)], | ||||||||||
| 93 | ); | ||||||||||
| 94 | } else { | ||||||||||
| 95 | Exception::Moose->throw( | ||||||||||
| 96 | message => $info, | ||||||||||
| 97 | 0 | ▶ | longmess => exists $args{longmess} ? !!$args{longmess} : 0, | ||||||||
|
Branch: 1 branch
| |||||||||||
| 98 | ignore_class => | ||||||||||
| 99 | [qw(MooseX::Error::Exception::Class Moose::Meta::Class)], | ||||||||||
| 100 | ); | ||||||||||
| 101 | } | ||||||||||
| 102 | |||||||||||
| 103 | 0 | return; | |||||||||
| 104 | } ## end sub _create_error | ||||||||||
| 105 | |||||||||||
| 106 | 2 | 1; # Magic true value required at end of module | |||||||||
| 107 | |||||||||||
| 108 | __END__ | ||||||||||