i make frequent use of die in eval blocks to trap errors.

my code often looks like this:
sub check_id { my ( $id )= @_; my $res; eval { my $obj= ObjClass::Obj->new(); $obj->id( $id ); $obj->load_via_id() ; $res= $obj->id ; die "invalid user" unless $obj->activated_account ; } if ($@) { DEBUG && log_error( $@ ); return -1; } return $res; }
note, thats a simplified version.

my problem lies in these 2 lines:
$obj->load_via_id() ; die "invalid user" unless $obj->activated_account ;
load_via_id could die and toss an exception - at which point things work as they should. i want to catch that die.

my issue is that if i die on "invalid user" (note, this is a simple version, in practice, there could several of these custom die items chained, i want to treat that differently : i still want to die and exit the block and return an error , but I don't want to do the logging.

can anyone suggest a way to do that and keep a similar syntax/code ? the only thing i could figure out was to have a '$supress_warning' variable before the block, and set it for custom dies -- but that means i'd have to write the dies as
if ( !$obj->activated_account ) { $suppres_warning++; die "invalid account"; }
someone out there with more experience than me must have a suggestion! i hope!

In reply to novice 'die' help requested by nmerriweather

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.