From c949a56c80c3841176f8759dfbbe214eb412fac5 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 11 Apr 2005 15:17:17 +0000 Subject: [PATCH] added line to better report exceptions git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@271 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/Application.pm | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/perlmods/OpenSRF/Application.pm b/src/perlmods/OpenSRF/Application.pm index 34b41bd..65cd9df 100644 --- a/src/perlmods/OpenSRF/Application.pm +++ b/src/perlmods/OpenSRF/Application.pm @@ -147,7 +147,9 @@ sub handler { } } catch Error with { my $e = shift; - $e = $e->{-text} || $e->message if (ref $e); + if(UNIVERSAL::isa($e,"Error")) { + $e = $e->stringify(); + } my $sess_id = $session->session_id; $session->status( OpenSRF::DomainObject::oilsMethodException->new( @@ -192,10 +194,13 @@ sub handler { $log->debug( "Executed: " . $appreq->threadTrace, DEBUG ); } catch Error with { my $e = shift; + if(UNIVERSAL::isa($e,"Error")) { + $e = $e->stringify(); + } $session->status( OpenSRF::DomainObject::oilsMethodException->new( statusCode => STATUS_INTERNALSERVERERROR(), - status => "Call to [".$aref->[2]->api_name."] faild: ".$e->{-text} + status => "Call to [".$aref->[2]->api_name."] faild: $e" ) ); }; @@ -383,17 +388,30 @@ sub run { if (!$self->{remote}) { my $code ||= \&{$self->{package} . '::' . $self->{method}}; $log->debug("Created coderef [$code] for $$self{package}::$$self{method}",DEBUG); + my $err = undef; + try { $resp = $code->($self, $req, @params); + } catch Error with { my $e = shift; + $err = $e; warn "Caught Error in Application: $e\n"; if( ref($self) eq 'HASH') { + warn $self; $log->error("Sub $$self{package}::$$self{method} DIED!!!\n\t$e\n", ERROR); } - die $e; }; + if($err) { + if(UNIVERSAL::isa($err,"Error")) { + throw $err ($err->stringify); + } else { + die $err; + } + } + + $log->debug("Coderef for [$$self{package}::$$self{method}] has been run", DEBUG); if ( ref($req) and UNIVERSAL::isa($req, 'OpenSRF::AppSubrequest') ) { -- 2.11.0