|Subject:||CGI::Carp fatalsToBrowser does not catch stringifiable objects|
When an exception module like Exception::Class 1.24 is used that uses die and exception objects to throw exceptions, uncaught exceptions (effectively die calls with object references instead of strings) are not intercepted by CGI::Carp. After reviewing the source to both Exception::Class and CGI::Carp this is due to CGI::Carp's unwillingness to touch objects it does not understand (because it does not have a reliable way to stringify them?). Well Exception::Class overloads the "" operator to enable stringification if the caller expects strings. So in order to get CGI::Carp to intercept uncaught exceptions that are outside of an eval block, I had to add the following to CGI::Carp.pm 1.30_01: 318a319 Show quoted text
> use overload;443a445,446 Show quoted text
> $arg = "$arg" if overload::Method($arg, '""'); # Exception::Classstringification compatibility Show quoted text
>All this does is stringify an object if it has overloaded the "" operator. This allows CGI::Carp to intercept and reformat uncaught exceptions thrown from Exception modules implemented similar to Exception::Class. Also it is important that this line is placed after the ineval check block because it is likely exceptions should not be intercepted when they are thrown inside of an eval block. I believe eval is the only mechnism used to effectively catch exceptions.