File | /usr/local/lib/perl/5.10.0/Moose/Error/Default.pm |
Statements Executed | 20 |
Total Time | 0.0005241 seconds |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
0 | 0 | 0 | 0s | 0s | BEGIN | Moose::Error::Default::
0 | 0 | 0 | 0s | 0s | _create_error_carpmess | Moose::Error::Default::
0 | 0 | 0 | 0s | 0s | create_error_confess | Moose::Error::Default::
0 | 0 | 0 | 0s | 0s | create_error_croak | Moose::Error::Default::
0 | 0 | 0 | 0s | 0s | new | Moose::Error::Default::
Line | Stmts. | Exclusive Time | Avg. | Code |
---|---|---|---|---|
1 | package Moose::Error::Default; | |||
2 | ||||
3 | 3 | 28µs | 9µs | use strict; # spent 10µs making 1 call to strict::import |
4 | 3 | 51µs | 17µs | use warnings; # spent 23µs making 1 call to warnings::import |
5 | ||||
6 | 1 | 800ns | 800ns | our $VERSION = '1.15'; |
7 | 1 | 19µs | 19µs | $VERSION = eval $VERSION; |
8 | 1 | 700ns | 700ns | our $AUTHORITY = 'cpan:STEVAN'; |
9 | ||||
10 | 3 | 140µs | 47µs | use Carp::Heavy; # spent 4µs making 1 call to import |
11 | 3 | 24µs | 8µs | use Class::MOP::MiniTrait; # spent 3µs making 1 call to import |
12 | ||||
13 | 3 | 241µs | 80µs | use base 'Class::MOP::Object'; # spent 77µs making 1 call to base::import |
14 | ||||
15 | 1 | 6µs | 6µs | Class::MOP::MiniTrait::apply(__PACKAGE__, 'Moose::Meta::Object::Trait'); # spent 2.01ms making 1 call to Class::MOP::MiniTrait::apply |
16 | ||||
17 | sub new { | |||
18 | my ( $self, @args ) = @_; | |||
19 | $self->create_error_confess( @args ); | |||
20 | } | |||
21 | ||||
22 | sub create_error_croak { | |||
23 | my ( $self, @args ) = @_; | |||
24 | $self->_create_error_carpmess( @args ); | |||
25 | } | |||
26 | ||||
27 | sub create_error_confess { | |||
28 | my ( $self, @args ) = @_; | |||
29 | $self->_create_error_carpmess( @args, longmess => 1 ); | |||
30 | } | |||
31 | ||||
32 | sub _create_error_carpmess { | |||
33 | my ( $self, %args ) = @_; | |||
34 | ||||
35 | my $carp_level = 3 + ( $args{depth} || 1 ); | |||
36 | local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though | |||
37 | ||||
38 | my @args = exists $args{message} ? $args{message} : (); | |||
39 | ||||
40 | if ( $args{longmess} || $Carp::Verbose ) { | |||
41 | local $Carp::CarpLevel = ( $Carp::CarpLevel || 0 ) + $carp_level; | |||
42 | return Carp::longmess(@args); | |||
43 | } else { | |||
44 | return Carp::ret_summary($carp_level, @args); | |||
45 | } | |||
46 | } | |||
47 | ||||
48 | 1 | 14µs | 14µs | __PACKAGE__ |
49 | ||||
50 | __END__ | |||
51 | ||||
52 | =pod | |||
53 | ||||
54 | =head1 NAME | |||
55 | ||||
56 | Moose::Error::Default - L<Carp> based error generation for Moose. | |||
57 | ||||
58 | =head1 DESCRIPTION | |||
59 | ||||
60 | This class implements L<Carp> based error generation. | |||
61 | ||||
62 | The default behavior is like L<Moose::Error::Confess>. | |||
63 | ||||
64 | =head1 METHODS | |||
65 | ||||
66 | =over 4 | |||
67 | ||||
68 | =item new @args | |||
69 | ||||
70 | Create a new error. Delegates to C<create_error_confess>. | |||
71 | ||||
72 | =item create_error_confess @args | |||
73 | ||||
74 | =item create_error_croak @args | |||
75 | ||||
76 | Creates a new errors string of the specified style. | |||
77 | ||||
78 | =back | |||
79 | ||||
80 | =cut | |||
81 | ||||
82 |