Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Using Perl Exception Class

by Perllace (Acolyte)
on Apr 20, 2011 at 10:51 UTC ( [id://900307]=note: print w/replies, xml ) Need Help??


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

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..

Replies are listed 'Best First'.
Re^5: Using Perl Exception Class
by Corion (Patriarch) on Apr 20, 2011 at 11:29 UTC

    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://900307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (8)
As of 2024-04-23 09:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found