This is one for the monks of dubious purity who don't baulk at the thought of overriding die.

I have a package (with parts borrowed and munged from some existing CPAN modules whose names escape me) that replaces die with a handler to make a useful web error page on die - with stack traces etc.

I just had it throw up a very unusual case. The stack trace shows the following:

my_sybase_error_handler() : die "foo"; Sybase::DBlib nsql() Line: 429 : $db->dbsqlexec; my_app_code() : eval {$dbh->nsql;};
Sybase::DBLib allows you to register an error handler that will be called if dbsqlexec detects an error, which is what gets called in the final instance. Clearly the die should be caught by the eval, but instead my web error page gets displayed.

I'm replacing die by assigning the glob of my web error handler to *CORE::GLOBAL::die. perlvar suggests doing this so I don't have to deal with checking $^S which indicates to me that my handler won't get called when something die's within an eval.

That seems to be wrong in this case. Unfortunately this particular application is running that most unfortunate of perl versions 5.6.0 which may have some bearing on the matter.

Next I'm going to run some tests to see if $^S can be set when my die replacement is called, but since I don't even know if it *is* called in this instance (perhaps it is the stack trace that is lying) then my results may not be conclusive.


In reply to Overriding CORE::GLOBAL::die and $^S by aufflick

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.