Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Exception::Class - how to use?

by Perllace (Acolyte)
on Apr 20, 2011 at 11:57 UTC ( #900319=note: print w/ replies, xml ) Need Help??

in reply to Exception::Class - how to use?

Hi monks, I have a similar problem...I'm not sure how to use this package..moreover, I'm not sure if this package is actually right to meet my needs either.. Please have a look

package MyExceptions; use strict; use warnings; use Exception::Class ( 'MyExceptions', 'MyExceptions::RegionNotFound' => { isa => 'MyExceptions' }, 'MyExceptions::CommandNotExecuted' => { isa => 'MyExceptions' } ); 1;

Then I have another module to report the exceptions handled

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'); #how do I do it?? }

The user would script something like this

Could you throw some light on this please..I have no idea is this kind of exception handling is the right way either..

Comment on Re: Exception::Class - how to use?
Select or Download Code
Replies are listed 'Best First'.
Re^2: Exception::Class - how to use?
by Corion (Pope) on Apr 20, 2011 at 11:59 UTC

    See Using Perl Exception Class.

    It makes little sense to ask the same question in two locations, especially in a thread that is 5 years old.

      Yes Corion..was in fix to get this done and... i didn't notice that the thread was 5 years old.. cud finally figure out how to do this ...
      use Exception::Class ( 'MyExceptions::Test' => { fields => [qw{message}], } ); use Moose::Util::TypeConstraints; class_type 'MyExceptions::ExecutionTest'; no Moose::Util::TypeConstraints; 1;
      then to throw the exception
      MyExceptions::ExceptionTest->throw( message => $data )
      then the script has something like
      if ( my $ex = $@ ) { my $e; if ( $e = Exception::Class->caught('MyExceptions::ExecutionTest')) { print $e->message; } }
      Thanks for your help

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2015-11-27 13:09 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (729 votes), past polls