From 1fa01c61ed62d30ce23566b32ab4c7014de4372d Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Mon, 20 Dec 2010 02:13:08 +1300 Subject: [PATCH 1/3] Fix for caller_info on <=5.10.1 --- Changes | 5 +++++ lib/Data/Handle/Exception.pm | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index ef409eb..31db624 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,11 @@ Revision history for {{$dist->name}} {{$NEXT}} + The method we were borrowing out of Carp wasn't there in old versions, + so we've added a bit of magic to try get it from older carps too, so we don't fail + on <= 5.10.1 :( + + 0.01011500 2010-12-20 01:36:06 Pacific/Auckland More tests to improve general function coverage diff --git a/lib/Data/Handle/Exception.pm b/lib/Data/Handle/Exception.pm index d1d5c73..a14ed9c 100644 --- a/lib/Data/Handle/Exception.pm +++ b/lib/Data/Handle/Exception.pm @@ -65,6 +65,17 @@ sub throw { my @stack = (); my @stacklines = (); + my $callerinfo; + + if ( not defined &Carp::caller_info ) { + ## no critic (RequireBarewordIncludes, ProhibitPunctuationVars ) + require 'Carp/Heavy.pm' unless $^O eq 'MSWin32'; + require 'Carp\Heavy.pm' if $^O eq 'MSWin32'; + $callerinfo = \&Carp::Heavy::caller_info; + } + else { + $callerinfo = \&Carp::caller_info; + } { # stolen parts from Carp::ret_backtrace my ($i) = 0; @@ -74,12 +85,12 @@ sub throw { $tid_msg = " thread $tid" if $tid; } - my %i = Carp::caller_info($i); + my %i = $callerinfo->($i); push @stack, \%i; push @stacklines, sprintf q{Exception '%s' thrown at %s line %s%s}, blessed($self), $i{file}, $i{line}, $tid_msg; - while ( my %j = Carp::caller_info( ++$i ) ) { + while ( my %j = $callerinfo->( ++$i ) ) { push @stack, \%j; push @stacklines, sprintf q{%s called at %s line %s%s}, $j{sub_name}, $j{file}, $j{line}, $tid_msg; } @@ -177,9 +188,7 @@ sub _gen { sub _gen_tree { my ( $self, $class ) = @_; my $parent = $class; - require Carp; - # Carp::carp("Generating $class."); $parent =~ s{ ::[^:]+$ }{}x; From bd3d83180bb2b40bbb61fe65993461999a3df5dc Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Mon, 20 Dec 2010 02:15:30 +1300 Subject: [PATCH 2/3] update changelog --- Changes | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Changes b/Changes index 31db624..220bf31 100644 --- a/Changes +++ b/Changes @@ -5,6 +5,10 @@ Revision history for {{$dist->name}} The method we were borrowing out of Carp wasn't there in old versions, so we've added a bit of magic to try get it from older carps too, so we don't fail on <= 5.10.1 :( + + Changes | 11 +++++++++++ + lib/Data/Handle/Exception.pm | 17 +++++++++++++---- + 2 files changed, 24 insertions(+), 4 deletions(-) 0.01011500 2010-12-20 01:36:06 Pacific/Auckland From 6b6ec9915b3a0b2cb20bfc6fe48e9cc2b1427d47 Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Mon, 20 Dec 2010 02:16:20 +1300 Subject: [PATCH 3/3] v0.01011501 The method we were borrowing out of Carp wasn't there in old versions, so we've added a bit of magic to try get it from older carps too, so we don't fail on <= 5.10.1 :( Changes | 11 +++++++++++ lib/Data/Handle/Exception.pm | 17 +++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) --- Changes | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changes b/Changes index 220bf31..abc4d77 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,8 @@ Revision history for {{$dist->name}} {{$NEXT}} +0.01011501 2010-12-20 02:15:59 Pacific/Auckland + The method we were borrowing out of Carp wasn't there in old versions, so we've added a bit of magic to try get it from older carps too, so we don't fail on <= 5.10.1 :(