| Filename | /2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/DBIx/Class/Exception.pm |
| Statements | Executed 35 statements in 1.43ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 4 | 1 | 1 | 98µs | 4.24ms | DBIx::Class::Exception::throw |
| 1 | 1 | 1 | 12µs | 49µs | DBIx::Class::Exception::BEGIN@9 |
| 1 | 1 | 1 | 12µs | 14µs | DBIx::Class::Exception::BEGIN@3 |
| 1 | 1 | 1 | 7µs | 14µs | DBIx::Class::Exception::BEGIN@4 |
| 2 | 1 | 1 | 5µs | 5µs | DBIx::Class::Exception::CORE:subst (opcode) |
| 1 | 1 | 1 | 4µs | 4µs | DBIx::Class::Exception::BEGIN@6 |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Exception::__ANON__[:9] |
| 0 | 0 | 0 | 0s | 0s | DBIx::Class::Exception::rethrow |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package DBIx::Class::Exception; | ||||
| 2 | |||||
| 3 | 3 | 22µs | 2 | 16µs | # spent 14µs (12+2) within DBIx::Class::Exception::BEGIN@3 which was called:
# once (12µs+2µs) by DBIx::Class::Row::BEGIN@8 at line 3 # spent 14µs making 1 call to DBIx::Class::Exception::BEGIN@3
# spent 2µs making 1 call to strict::import |
| 4 | 3 | 16µs | 2 | 21µs | # spent 14µs (7+7) within DBIx::Class::Exception::BEGIN@4 which was called:
# once (7µs+7µs) by DBIx::Class::Row::BEGIN@8 at line 4 # spent 14µs making 1 call to DBIx::Class::Exception::BEGIN@4
# spent 7µs making 1 call to warnings::import |
| 5 | |||||
| 6 | 3 | 45µs | 1 | 4µs | # spent 4µs within DBIx::Class::Exception::BEGIN@6 which was called:
# once (4µs+0s) by DBIx::Class::Row::BEGIN@8 at line 6 # spent 4µs making 1 call to DBIx::Class::Exception::BEGIN@6 |
| 7 | |||||
| 8 | use overload | ||||
| 9 | # spent 49µs (12+37) within DBIx::Class::Exception::BEGIN@9 which was called:
# once (12µs+37µs) by DBIx::Class::Row::BEGIN@8 at line 10 | ||||
| 10 | 3 | 174µs | 2 | 86µs | fallback => 1; # spent 49µs making 1 call to DBIx::Class::Exception::BEGIN@9
# spent 37µs making 1 call to overload::import |
| 11 | |||||
| 12 | =head1 NAME | ||||
| 13 | |||||
| 14 | DBIx::Class::Exception - Exception objects for DBIx::Class | ||||
| 15 | |||||
| 16 | =head1 DESCRIPTION | ||||
| 17 | |||||
| 18 | Exception objects of this class are used internally by | ||||
| 19 | the default error handling of L<DBIx::Class::Schema/throw_exception> | ||||
| 20 | and derivatives. | ||||
| 21 | |||||
| 22 | These objects stringify to the contained error message, and use | ||||
| 23 | overload fallback to give natural boolean/numeric values. | ||||
| 24 | |||||
| 25 | =head1 METHODS | ||||
| 26 | |||||
| 27 | =head2 throw | ||||
| 28 | |||||
| 29 | =over 4 | ||||
| 30 | |||||
| 31 | =item Arguments: $exception_scalar, $stacktrace | ||||
| 32 | |||||
| 33 | =back | ||||
| 34 | |||||
| 35 | This is meant for internal use by L<DBIx::Class>'s C<throw_exception> | ||||
| 36 | code, and shouldn't be used directly elsewhere. | ||||
| 37 | |||||
| 38 | Expects a scalar exception message. The optional argument | ||||
| 39 | C<$stacktrace> tells it to output a full trace similar to L<Carp/confess>. | ||||
| 40 | |||||
| 41 | DBIx::Class::Exception->throw('Foo'); | ||||
| 42 | try { ... } catch { DBIx::Class::Exception->throw(shift) } | ||||
| 43 | |||||
| 44 | =cut | ||||
| 45 | |||||
| 46 | # spent 4.24ms (98µs+4.14) within DBIx::Class::Exception::throw which was called 4 times, avg 1.06ms/call:
# 4 times (98µs+4.14ms) by DBIx::Class::Schema::throw_exception at line 1088 of DBIx/Class/Schema.pm, avg 1.06ms/call | ||||
| 47 | 18 | 1.15ms | my ($class, $msg, $stacktrace) = @_; | ||
| 48 | |||||
| 49 | # Don't re-encapsulate exception objects of any kind | ||||
| 50 | die $msg if ref($msg); | ||||
| 51 | |||||
| 52 | # all exceptions include a caller | ||||
| 53 | 2 | 5µs | $msg =~ s/\n$//; # spent 5µs making 2 calls to DBIx::Class::Exception::CORE:subst, avg 2µs/call | ||
| 54 | |||||
| 55 | 4 | 21µs | if(!$stacktrace) { | ||
| 56 | # skip all frames that match the original caller, or any of | ||||
| 57 | # the dbic-wide classdata patterns | ||||
| 58 | 2 | 4.14ms | my ($ln, $calling) = DBIx::Class::Carp::__find_caller( # spent 4.14ms making 2 calls to DBIx::Class::Carp::__find_caller, avg 2.07ms/call | ||
| 59 | '^' . caller() . '$', | ||||
| 60 | 'DBIx::Class', | ||||
| 61 | ); | ||||
| 62 | |||||
| 63 | $msg = "${calling}${msg} ${ln}\n"; | ||||
| 64 | } | ||||
| 65 | else { | ||||
| 66 | $msg = Carp::longmess($msg); | ||||
| 67 | } | ||||
| 68 | |||||
| 69 | my $self = { msg => $msg }; | ||||
| 70 | bless $self => $class; | ||||
| 71 | |||||
| 72 | die $self; | ||||
| 73 | } | ||||
| 74 | |||||
| 75 | =head2 rethrow | ||||
| 76 | |||||
| 77 | This method provides some syntactic sugar in order to | ||||
| 78 | re-throw exceptions. | ||||
| 79 | |||||
| 80 | =cut | ||||
| 81 | |||||
| 82 | sub rethrow { | ||||
| 83 | die shift; | ||||
| 84 | } | ||||
| 85 | |||||
| 86 | =head1 AUTHORS | ||||
| 87 | |||||
| 88 | Brandon L. Black <blblack@gmail.com> | ||||
| 89 | |||||
| 90 | =head1 LICENSE | ||||
| 91 | |||||
| 92 | You may distribute this code under the same terms as Perl itself. | ||||
| 93 | |||||
| 94 | =cut | ||||
| 95 | |||||
| 96 | 1 | 2µs | 1; | ||
# spent 5µs within DBIx::Class::Exception::CORE:subst which was called 2 times, avg 2µs/call:
# 2 times (5µs+0s) by DBIx::Class::Exception::throw at line 53, avg 2µs/call |