← Index
NYTProf Performance Profile   « line view »
For /home/ss5/perl5/perlbrew/perls/perl-5.22.0/bin/benchmarkanything-storage
  Run on Mon Jan 29 16:55:34 2018
Reported on Mon Jan 29 16:57:07 2018

Filename/home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/Search/Elasticsearch/Error.pm
StatementsExecuted 25 statements in 467µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11114µs39µsSearch::Elasticsearch::Error::::BEGIN@40Search::Elasticsearch::Error::BEGIN@40
1113µs3µsSearch::Elasticsearch::Error::::BEGIN@45Search::Elasticsearch::Error::BEGIN@45
0000s0sSearch::Elasticsearch::Error::::TO_JSONSearch::Elasticsearch::Error::TO_JSON
0000s0sSearch::Elasticsearch::Error::::_compareSearch::Elasticsearch::Error::_compare
0000s0sSearch::Elasticsearch::Error::::_stackSearch::Elasticsearch::Error::_stack
0000s0sSearch::Elasticsearch::Error::::_stringifySearch::Elasticsearch::Error::_stringify
0000s0sSearch::Elasticsearch::Error::::isSearch::Elasticsearch::Error::is
0000s0sSearch::Elasticsearch::Error::::newSearch::Elasticsearch::Error::new
0000s0sSearch::Elasticsearch::Error::::stacktraceSearch::Elasticsearch::Error::stacktrace
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Search::Elasticsearch::Error;
21200ns$Search::Elasticsearch::Error::VERSION = '5.01';
31200nsour $DEBUG = 0;
4
514µs@Search::Elasticsearch::Error::Internal::ISA = __PACKAGE__;
611µs@Search::Elasticsearch::Error::Param::ISA = __PACKAGE__;
711µs@Search::Elasticsearch::Error::NoNodes::ISA = __PACKAGE__;
811µs@Search::Elasticsearch::Error::Unauthorized::ISA = __PACKAGE__;
91900ns@Search::Elasticsearch::Error::Forbidden::ISA = __PACKAGE__;
1011µs@Search::Elasticsearch::Error::Illegal::ISA = __PACKAGE__;
111900ns@Search::Elasticsearch::Error::Request::ISA = __PACKAGE__;
1212µs@Search::Elasticsearch::Error::Timeout::ISA = __PACKAGE__;
1312µs@Search::Elasticsearch::Error::Cxn::ISA = __PACKAGE__;
1411µs@Search::Elasticsearch::Error::Serializer::ISA = __PACKAGE__;
15
16@Search::Elasticsearch::Error::Conflict::ISA
1713µs = ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ );
18
19@Search::Elasticsearch::Error::Missing::ISA
2012µs = ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ );
21
22@Search::Elasticsearch::Error::RequestTimeout::ISA
2311µs = ( 'Search::Elasticsearch::Error::Request', __PACKAGE__ );
24
25@Search::Elasticsearch::Error::ContentLength::ISA
2612µs = ( __PACKAGE__, 'Search::Elasticsearch::Error::Request' );
27
28@Search::Elasticsearch::Error::SSL::ISA
2914µs = ( __PACKAGE__, 'Search::Elasticsearch::Error::Cxn' );
30
31@Search::Elasticsearch::Error::BadGateway::ISA
3212µs = ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ );
33
34@Search::Elasticsearch::Error::Unavailable::ISA
3512µs = ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ );
36
37@Search::Elasticsearch::Error::GatewayTimeout::ISA
3811µs = ( 'Search::Elasticsearch::Error::Cxn', __PACKAGE__ );
39
40
# spent 39µs (14+25) within Search::Elasticsearch::Error::BEGIN@40 which was called: # once (14µs+25µs) by Search::Elasticsearch::Util::BEGIN@4 at line 43
use overload (
4115µs125µs '""' => '_stringify',
# spent 25µs making 1 call to overload::import
42 'cmp' => '_compare',
43114µs139µs);
# spent 39µs making 1 call to Search::Elasticsearch::Error::BEGIN@40
44
452410µs13µs
# spent 3µs within Search::Elasticsearch::Error::BEGIN@45 which was called: # once (3µs+0s) by Search::Elasticsearch::Util::BEGIN@4 at line 45
use Data::Dumper();
# spent 3µs making 1 call to Search::Elasticsearch::Error::BEGIN@45
46
47#===================================
48sub new {
49#===================================
50 my ( $class, $type, $msg, $vars, $caller ) = @_;
51 return $type if ref $type;
52 $caller ||= 0;
53
54 my $error_class = 'Search::Elasticsearch::Error::' . $type;
55 $msg = 'Unknown error' unless defined $msg;
56
57 local $DEBUG = 2 if $type eq 'Internal';
58
59 my $stack = $class->_stack;
60
61 my $self = bless {
62 type => $type,
63 text => $msg,
64 vars => $vars,
65 stack => $stack,
66 }, $error_class;
67
68 return $self;
69}
70
71#===================================
72sub is {
73#===================================
74 my $self = shift;
75 for (@_) {
76 return 1 if $self->isa("Search::Elasticsearch::Error::$_");
77 }
78 return 0;
79}
80
81#===================================
82sub _stringify {
83#===================================
84 my $self = shift;
85 local $Data::Dumper::Terse = 1;
86 local $Data::Dumper::Indent = !!$DEBUG;
87
88 unless ( $self->{msg} ) {
89 my $stack = $self->{stack};
90 my $caller = $stack->[0];
91 $self->{msg} = sprintf( "[%s] ** %s, called from sub %s at %s line %d.",
92 $self->{type}, $self->{text}, @{$caller}[ 3, 1, 2 ] );
93
94 if ( $self->{vars} ) {
95 $self->{msg} .= sprintf( " With vars: %s\n",
96 Data::Dumper::Dumper $self->{vars} );
97 }
98
99 if ( @$stack > 1 ) {
100 $self->{msg}
101 .= sprintf( "Stacktrace:\n%s\n", $self->stacktrace($stack) );
102 }
103 }
104 return $self->{msg};
105
106}
107
108#===================================
109sub _compare {
110#===================================
111 my ( $self, $other, $swap ) = @_;
112 $self .= '';
113 ( $self, $other ) = ( $other, $self ) if $swap;
114 return $self cmp $other;
115}
116
117#===================================
118sub _stack {
119#===================================
120 my $self = shift;
121 my $caller = shift() || 2;
122
123 my @stack;
124 while ( my @caller = caller( ++$caller ) ) {
125 next if $caller[0] eq 'Try::Tiny';
126
127 if ( $caller[3] =~ /^(.+)::__ANON__\[(.+):(\d+)\]$/ ) {
128 @caller = ( $1, $2, $3, '(ANON)' );
129 }
130 elsif ( $caller[1] =~ /^\(eval \d+\)/ ) {
131 $caller[3] = "modified(" . $caller[3] . ")";
132 }
133
134 next
135 if $caller[0] =~ /^Search::Elasticsearch/
136 and ( $DEBUG < 2 or $caller[3] eq 'Try::Tiny::try' );
137 push @stack, [ @caller[ 0, 1, 2, 3 ] ];
138 last unless $DEBUG > 1;
139 }
140 return \@stack;
141}
142
143#===================================
144sub stacktrace {
145#===================================
146 my $self = shift;
147 my $stack = shift || $self->_stack();
148
149 my $o = sprintf "%s\n%-4s %-50s %-5s %s\n%s\n",
150 '-' x 80, '#', 'Package', 'Line', 'Sub-routine', '-' x 80;
151
152 my $i = 1;
153 for (@$stack) {
154 $o .= sprintf "%-4d %-50s %4d %s\n", $i++, @{$_}[ 0, 2, 3 ];
155 }
156
157 return $o .= ( '-' x 80 ) . "\n";
158}
159
160#===================================
161sub TO_JSON {
162#===================================
163 my $self = shift;
164 return $self->_stringify;
165}
16615µs1;
167
168# ABSTRACT: Errors thrown by Search::Elasticsearch
169
170__END__