[Catalyst] Stack tracing exceptions
Matt S Trout
dbix-class at trout.me.uk
Sat Dec 10 03:39:50 CET 2005
On Fri, Dec 09, 2005 at 08:02:00AM -0600, Brandon Black wrote:
> The bigger issue, IMHO, is that exceptions provide no stack trace.
Try applying the following patch to trunk and see how you go. It manages
the stack trace part, but the trace is maybe a little verbose as yet (hence
why it's a patch rather than a commit). An example stack trace follows the
patch.
=== lib/Catalyst.pm
==================================================================
--- lib/Catalyst.pm (revision 4486)
+++ lib/Catalyst.pm (local)
@@ -18,6 +18,7 @@
use URI;
use Scalar::Util qw/weaken/;
use attributes;
+use Carp ();
__PACKAGE__->mk_accessors(
qw/counter request response state action stack namespace/
@@ -1094,6 +1095,12 @@
sub handle_request {
my ( $class, @arguments ) = @_;
+ local $SIG{__DIE__} =
+ sub {
+ return if $_[0] eq $Catalyst::DETACH;
+ die Carp::longmess(@_);
+ };
+
# Always expect worst case!
my $status = -1;
eval {
####################### END OF PATCH
####################### SAMPLE STACK TRACE
Caught exception in TestApp::Controller::Engine::Response::Errors->one "Illegal division by zero at /usr/home/matthewt/wdir/Catalyst/trunk/Catalyst/t/lib/TestApp/Controller/Engine/Response/Errors.pm line 10.
at /usr/home/matthewt/wdir/Catalyst/trunk/Catalyst/t/lib/TestApp/Controller/Engine/Response/Errors.pm line 10
TestApp::Controller::Engine::Response::Errors::one('TestApp::Controller::Engine::Response::Errors=HASH(0x86dbfbc)'
'TestApp=HASH(0x8855174)') called at lib/Catalyst.pm line 917
eval {...} called at lib/Catalyst.pm line 917
Catalyst::execute('TestApp=HASH(0x8855174)'
'TestApp::Controller::Engine::Response::Errors'
'Catalyst::Action=HASH(0x87768d4)') called at /usr/home/matthewt/wdir/Catalyst/trunk/Catalyst/t/lib/TestApp.pm line 50
TestApp::execute('TestApp=HASH(0x8855174)'
'TestApp::Controller::Engine::Response::Errors'
'Catalyst::Action=HASH(0x87768d4)') called at lib/Catalyst/Action.pm line 43
Catalyst::Action::execute('Catalyst::Action=HASH(0x87768d4)'
'TestApp=HASH(0x8855174)') called at lib/Catalyst/Base.pm line 46
Catalyst::Base::_ACTION('TestApp::Controller::Engine::Response::Errors=HASH(0x86dbfbc)'
'TestApp=HASH(0x8855174)') called at lib/Catalyst.pm line 917
eval {...} called at lib/Catalyst.pm line 917
Catalyst::execute('TestApp=HASH(0x8855174)'
'TestApp::Controller::Engine::Response::Errors'
'Catalyst::Action=HASH(0x8776f70)') called at /usr/home/matthewt/wdir/Catalyst/trunk/Catalyst/t/lib/TestApp.pm line 50
TestApp::execute('TestApp=HASH(0x8855174)'
'TestApp::Controller::Engine::Response::Errors'
'Catalyst::Action=HASH(0x8776f70)') called at lib/Catalyst/Action.pm line 43
Catalyst::Action::execute('Catalyst::Action=HASH(0x8776f70)'
'TestApp=HASH(0x8855174)') called at lib/Catalyst/Dispatcher.pm line 164
Catalyst::Dispatcher::forward('Catalyst::Dispatcher=HASH(0x854b14c)'
'TestApp=HASH(0x8855174)'
'_ACTION') called at lib/Catalyst.pm line 253
Catalyst::forward('TestApp=HASH(0x8855174)'
'_ACTION') called at lib/Catalyst/Base.pm line 20
Catalyst::Base::_DISPATCH('TestApp::Controller::Engine::Response::Errors=HASH(0x86dbfbc)'
'TestApp=HASH(0x8855174)') called at lib/Catalyst.pm line 917
eval {...} called at lib/Catalyst.pm line 917
Catalyst::execute('TestApp=HASH(0x8855174)'
'TestApp::Controller::Engine::Response::Errors'
'Catalyst::Action=HASH(0x8777180)') called at /usr/home/matthewt/wdir/Catalyst/trunk/Catalyst/t/lib/TestApp.pm line 50
TestApp::execute('TestApp=HASH(0x8855174)'
'TestApp::Controller::Engine::Response::Errors'
'Catalyst::Action=HASH(0x8777180)') called at lib/Catalyst/Action.pm line 43
Catalyst::Action::execute('Catalyst::Action=HASH(0x8777180)'
'TestApp=HASH(0x8855174)') called at lib/Catalyst/Dispatcher.pm line 164
Catalyst::Dispatcher::forward('Catalyst::Dispatcher=HASH(0x854b14c)'
'TestApp=HASH(0x8855174)'
'/engine/response/errors/_DISPATCH') called at lib/Catalyst.pm line 253
Catalyst::forward('TestApp=HASH(0x8855174)'
'/engine/response/errors/_DISPATCH') called at lib/Catalyst/Dispatcher.pm line 57
Catalyst::Dispatcher::dispatch('Catalyst::Dispatcher=HASH(0x854b14c)'
'TestApp=HASH(0x8855174)') called at lib/Catalyst.pm line 858
Catalyst::dispatch('TestApp=HASH(0x8855174)') called at lib/Catalyst.pm line 1112
Catalyst::__ANON__ called at lib/Catalyst.pm line 1129
eval {...} called at lib/Catalyst.pm line 1106
Catalyst::handle_request('TestApp') called at lib/Catalyst/Test.pm line 104
Catalyst::Test::local_request('TestApp'
'http://localhost/engine/response/errors/one') called at lib/Catalyst/Test.pm line 82
Catalyst::Test::__ANON__('http://localhost/engine/response/errors/one')
--
Matt S Trout Offering custom development, consultancy and support
Technical Director contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd. mst (at) shadowcatsystems.co.uk for more information
+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +
More information about the Catalyst
mailing list