Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Using Perl Exception Class

by Corion (Patriarch)
on Apr 20, 2011 at 09:37 UTC ( [id://900298]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using Perl Exception Class
in thread Using Perl Exception Class

Have you read the Exception::Class documentation I linked to previously? What concrete questions to you still have that the documentation does not answer?

Replies are listed 'Best First'.
Re^4: Using Perl Exception Class
by Perllace (Acolyte) on Apr 20, 2011 at 10:51 UTC
    Hi Corion, I'm sorry about this..I'm really ignorant about exceptions...

    As of now, I have a module of the kind

    package MyExceptions; use strict; use warnings; use Exception::Class ( 'MyExceptions', 'MyExceptions::RegionNotFound' => { isa => 'MyExceptions' }, 'MyExceptions::CommandNotExecuted' => { isa => 'MyExceptions' } );
    The other module is
    package ReportGenerator; use strict; use warnings; sub CheckResult { my ( $result, $info ) = @_; #Here is want to check of $result and throw an exception of the kin +d MyExceptions::RegionNotFound->throw(error => 'bad number'); #I'm not sure how to do this.. } 1;
    The user would inturn script something like this $Report->CheckResult($ABC->Command(100,100),"Tapping Home");

    Thanks for your help..

      Have you read the documentation I linked? Searching the documentation for "throw" shows me:

      # try eval { MyException->throw( error => 'I feel funny.' ) };

      If you are unclear about the concept of structured exceptions in Perl, I can only recommend to avoid them alltogether. Structured exceptions are not well-supported in Perl, as the common way of exceptions are strings, as documented in die. If you feel you need to use something else, you should have good reasons to do so.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://900298]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (1)
As of 2024-04-25 01:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found