File | /usr/local/lib/perl5/site_perl/5.10.1/darwin-2level/Moose/Error/Default.pm |
Statements Executed | 13 |
Statement Execution Time | 891µs |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
1 | 1 | 1 | 9.92ms | 10.0ms | BEGIN@10 | Moose::Error::Default::
1 | 1 | 1 | 18µs | 21µs | BEGIN@3 | Moose::Error::Default::
1 | 1 | 1 | 7µs | 16µs | BEGIN@4 | 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 | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | package Moose::Error::Default; | ||||
2 | |||||
3 | 3 | 21µs | 2 | 24µs | # spent 21µs (18+3) within Moose::Error::Default::BEGIN@3 which was called
# once (18µs+3µs) by Moose::Meta::Class::BEGIN@20 at line 3 # spent 21µs making 1 call to Moose::Error::Default::BEGIN@3
# spent 3µs making 1 call to strict::import |
4 | 3 | 39µs | 2 | 25µs | # spent 16µs (7+9) within Moose::Error::Default::BEGIN@4 which was called
# once (7µs+9µs) by Moose::Meta::Class::BEGIN@20 at line 4 # spent 16µs making 1 call to Moose::Error::Default::BEGIN@4
# spent 9µs making 1 call to warnings::import |
5 | |||||
6 | 1 | 2µs | our $VERSION = '0.98'; | ||
7 | 1 | 31µs | $VERSION = eval $VERSION; | ||
8 | 1 | 700ns | our $AUTHORITY = 'cpan:STEVAN'; | ||
9 | |||||
10 | 3 | 793µs | 1 | 10.0ms | # spent 10.0ms (9.92+84µs) within Moose::Error::Default::BEGIN@10 which was called
# once (9.92ms+84µs) by Moose::Meta::Class::BEGIN@20 at line 10 # spent 10.0ms making 1 call to Moose::Error::Default::BEGIN@10 |
11 | |||||
12 | |||||
13 | sub new { | ||||
14 | my ( $self, @args ) = @_; | ||||
15 | $self->create_error_confess( @args ); | ||||
16 | } | ||||
17 | |||||
18 | sub create_error_croak { | ||||
19 | my ( $self, @args ) = @_; | ||||
20 | $self->_create_error_carpmess( @args ); | ||||
21 | } | ||||
22 | |||||
23 | sub create_error_confess { | ||||
24 | my ( $self, @args ) = @_; | ||||
25 | $self->_create_error_carpmess( @args, longmess => 1 ); | ||||
26 | } | ||||
27 | |||||
28 | sub _create_error_carpmess { | ||||
29 | my ( $self, %args ) = @_; | ||||
30 | |||||
31 | my $carp_level = 3 + ( $args{depth} || 1 ); | ||||
32 | local $Carp::MaxArgNums = 20; # default is 8, usually we use named args which gets messier though | ||||
33 | |||||
34 | my @args = exists $args{message} ? $args{message} : (); | ||||
35 | |||||
36 | if ( $args{longmess} || $Carp::Verbose ) { | ||||
37 | local $Carp::CarpLevel = ( $Carp::CarpLevel || 0 ) + $carp_level; | ||||
38 | return Carp::longmess(@args); | ||||
39 | } else { | ||||
40 | return Carp::ret_summary($carp_level, @args); | ||||
41 | } | ||||
42 | } | ||||
43 | |||||
44 | 1 | 5µs | __PACKAGE__ | ||
45 | |||||
46 | __END__ | ||||
47 | |||||
48 | =pod | ||||
49 | |||||
50 | =head1 NAME | ||||
51 | |||||
52 | Moose::Error::Default - L<Carp> based error generation for Moose. | ||||
53 | |||||
54 | =head1 DESCRIPTION | ||||
55 | |||||
56 | This class implements L<Carp> based error generation. | ||||
57 | |||||
58 | The default behavior is like L<Moose::Error::Confess>. | ||||
59 | |||||
60 | =head1 METHODS | ||||
61 | |||||
62 | =over 4 | ||||
63 | |||||
64 | =item new @args | ||||
65 | |||||
66 | Create a new error. Delegates to C<create_error_confess>. | ||||
67 | |||||
68 | =item create_error_confess @args | ||||
69 | |||||
70 | =item create_error_croak @args | ||||
71 | |||||
72 | Creates a new errors string of the specified style. | ||||
73 | |||||
74 | =back | ||||
75 | |||||
76 | =cut | ||||
77 | |||||
78 |