Hi All,
I'm investigating this Error.pm module and can't seem to make it work as advertised. I'm running ActivePerl 5.8.8 on XP.
I created the following custom Exception:
package DB::DBException; use base qw(Error); sub new { my ($self, $msg) = @_; my @args = (); local $Error::Depth = $Error::Depth + 1; local $Error::Debug = 1; # Enables storing of stacktrace $self->SUPER::new(-text => $msg, @args); return $self; }

and a test.pl:
use strict; use warnings; use Error qw(:try); use DB::DBException; try { throw DB::DBException("Connect exception"); print "OK\n"; } catch DB::DBException with { print "DBException"; } catch Error with { print "Error"; }; print "finished";


My problem is that the DBException is never caught. This test alwasy ends up on the catch Error block. If I remove the catch Error block, the program then dies at the time the exception is thrown: DB::DBException at C:/Perl/site/lib/Error.pm line 184.
I think I pretty much followed the module example so what I am doing wrong there ?
Thanks for a little word of wisdom

In reply to Error.pm and custom Exception by jbenezech

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.