bigpresh / Dancer-Plugin-Database

Dancer::Plugin::Database - easy database support for Dancer applications
http://search.cpan.org/dist/Dancer-Plugin-Database
37 stars 36 forks source link

Convenience functions break stacktrace #51

Open asergei opened 10 years ago

asergei commented 10 years ago

When an error occurs while using any of convenience functions like quick_select, Dancer is not able to produce a usable stack trace. The error is shown to be originating always from the same line of code in the Database::Handle module. I.e. where that actual call to DBI is made.

Apparently, this has something to do with Carp not being able to track inheritance from DBI correctly.

Update: Upon looking through DBI internals, it seems that DBI implements Carp.pm-like functionality on its own which does not work exactly the same. That's why it is impossible to fix this problem adjusting variables like @CARP_NOT, $CarpLevel in Carp.pm. When an error occurs during SQL statement execution, DBI looks down the calling chain and finds the first module outside of DBI or DBD namespace and reports this module in its error message. Even if this module is a subclass of DBI. So, the only solution would be to catch and rethrow the error.

bigpresh commented 9 years ago

Hmm - yeah, catching the error would probably work. I'll look in to this. It might also be worth suggesting to TIMB that perhaps excluding modules which inherit from DBI would be worth including?