Error.pm Perl Cpan
Contents |
POD CPAN RT New 1 Open 0 View/Report Bugs Module Version: 0.17022 Source LatestRelease:Error-0.17024 NAME WARNING SYNOPSIS DESCRIPTION PROCEDURAL INTERFACE COMPATIBILITY CLASS INTERFACE CONSTRUCTORS STATIC METHODS OBJECT METHODS OVERLOAD perl error variable METHODS PRE-DEFINED ERROR CLASSES Error::Simple $Error::ObjectifyCallback MESSAGE HANDLERS EXAMPLE SEE ALSO KNOWN perl-error rpm BUGS AUTHORS MAINTAINER PAST MAINTAINERS COPYRIGHT NAME Error - Error/exception handling in an OO-ish way WARNING Using the
Perl Exception Handling
"Error" module is no longer recommended due to the black-magical nature of its syntactic sugar, which often tends to break. Its maintainers have stopped actively writing code that uses it,
Perl Throw
and discourage people from doing so. See the "SEE ALSO" section below for better recommendations. SYNOPSIS use Error qw(:try); throw Error::Simple( "A simple error"); sub xyz { ... record Error::Simple("A simple error") and return; } unlink($file) or throw Error::Simple("$file: $!",$!); try { do_some_stuff(); die "error!" if $condition; throw Error::Simple "Oops!" if $other_condition; } catch Error::IO with { my $E = shift; perl error handling print STDERR "File ", $E->{'-file'}, " had a problem\n"; } except { my $E = shift; my $general_handler=sub {send_message $E->{-description}}; return { UserException1 => $general_handler, UserException2 => $general_handler }; } otherwise { print STDERR "Well I don't know what to say\n"; } finally { close_the_garage_door_already(); # Should be reliable }; # Don't forget the trailing ; or you might be surprised DESCRIPTION The Error package provides two interfaces. Firstly Error provides a procedural interface to exception handling. Secondly Error is a base class for errors/exceptions that can either be thrown, for subsequent catch, or can simply be recorded. Errors in the class Error should not be thrown directly, but the user should throw errors from a sub-class of Error. PROCEDURAL INTERFACE Error exports subroutines to perform exception handling. These will be exported if the :try tag is used in the use line. try BLOCK CLAUSES try is the main subroutine called by the user. All other subroutines exported are clauses to the try subroutine. The BLOCK will be evaluated and, if no error is throw, try will return the result
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us
Perl Try::tiny
Learn more about Stack Overflow the company Business Learn more about hiring developers or perl eval posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why do I get this module error: “Can't http://search.cpan.org/~shlomif/Error-0.17022/lib/Error.pm locate Error.pm in @INC”? up vote 3 down vote favorite I tried running: perl -e "use Error;" from cmd in windows 7. (active perl 5.12 installed on system) and I am getting the error Can't locate Error.pm in @INC (@INC contains: C:/Perl64/site/lib C:/Perl64/lib ) I manually searched and found Error.pm in C:/Perl64/lib/CPANPLUS. Does anyone have an idea what could be going on here? perl module share|improve this question http://stackoverflow.com/questions/3303641/why-do-i-get-this-module-error-cant-locate-error-pm-in-inc edited Jul 22 '10 at 3:24 toolic 30.5k43468 asked Jul 21 '10 at 20:41 chuck taylor 1,02721735 1 Sounds like your cpanplus was misconfigured, so it installed libraries in the wrong place. –Ether Jul 21 '10 at 21:21 4 Answerers on crack again today; the question clearly asks about Error and everyone talks about the irrelevant CPANPLUS::Error. chuck, you just have to install this missing module before you can use it. See stackoverflow.com/questions/65865/… –daxim Jul 22 '10 at 7:55 This worked for me. Thanks daxim. –chuck taylor Jul 22 '10 at 13:46 add a comment| 4 Answers 4 active oldest votes up vote 3 down vote You have to install the module Error that can be found on CPAN. But be aware of this warning: Using the "Error" module is no longer recommended due to the black-magical nature of its syntactic sugar, which often tends to break. Its maintainers have stopped actively writing code that uses it, and discourage people from doing so. See the "SEE ALSO" section below for better recommendations. share|improve this answer edited Jul 22 '10 at 9:01 daxim 33.9k44198 answered Jul 22 '10 at 8:06 Toto 47.1k163981 Why the downvo
exceptions of a certain class perl error explicitly, and differentiate between several types of exceptions. Error.pm provides a lot of syntactic sugar that tends to break easily. As error.pm perl cpan such, its use is not too recommended. On the other side, there's the Exception-Class module which provides object-oriented exceptions with no special syntactic sugar, and which works very well. Its use is highly recommended. Throwing objects which are associated with classes is a good way to be able to handle one's exceptions programatically . Contents Up Prev Next Written by Shlomi Fish