Error.pm Perl Module
Contents |
Dependencies Annotate this POD CPAN RT Open 0 View/Report Bugs Module Version: 0.07 Source NAME SYNOPSIS DESCRIPTION FUNCTIONS EXCEPTION CLASSES CAVEATS BUGS SEE ALSO AUTHOR COPYRIGHT & LICENSE NAME Error::TryCatch - OO-ish perl error variable Exception Handling through source filtering SYNOPSIS use Error::TryCatch; try { dangerous_code(); even_more_dangerous_code(); throw perl-error rpm new Error::Generic -text => "well, no one can live in danger forever"; } catch Error::Unhandled with { # normal perl throw die()s are translated into Error::Unhandled exceptions print "caught an unhandled perl exception: $@\n"; } catch Error::NewExceptionClass with { # code that handles Error::NewExceptionClass } catch Error::YetAnotherExceptions { # note that 'with' is perl exception handling optional (this differs from Error.pm) } otherwise { # catch any other exception which might not have been caught my $exception_class = ref($@}; print "someone has thrown a $exception_class exception: $@\n"; } finally { clean_up(); # which will always be executed }; # don't forget the trailing ';' otherwise bad things *will* happen DESCRIPTION Error::TryCatch implements exception handling (try-catch) blocks functionality with an
Perl Error Handling
interface similiar to Error.pm (in fact, it's almost a drop-in replacement). The main difference is that it's a source filter module. As a source filter it can implement the same convenient interface without those nasty memory leaks and implicit anonymous subroutines (which can trick you, if you're not careful). Also after source parsing it converts the code into "native" perl code, so it's probably a little faster than Error.pm's approach. And, well. As far as I can tell, Error::TryCatch accomplishes its duty nicely. FUNCTIONS The interface is pretty straight-forward. I think that reading the synopsis is enough documentation. If you *really* need an explanation about how exception handling blocks work, you should take a look at Error.pm documentation. The only clause which I chose not to implement was the 'except' clause, since I consider it rather "exotic" and pretty much useless (at least for my purposes). And it would be a pain to implement. Unlike Error.pm, with Error::TryCatch you can return() from anywhere, but see CAVEATS below. EXCEPTION CLASSES Error::TryCatch was built with exception classes in mind and will even wrap anything it catches that is not a referen
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 Learn more about Stack Overflow the company Business Learn more about hiring developers
Perl Try::tiny
or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x perl eval 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 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 http://search.cpan.org/~nilsonsfj/Error-TryCatch-0.07/lib/Error/TryCatch.pm 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 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 http://stackoverflow.com/questions/3303641/why-do-i-get-this-module-error-cant-locate-error-pm-in-inc 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 downvotes ? –Toto Jul 22 '10 at 13:02 1 To do this, run sudo cpan Error –Alastair Irvine Nov 20 '13 at 4:08 add a comment| up vote 1 down vote lib/CPANPLUS/Error.pm is a core "CPANPLUS::Error" module. It is used by CPANPLUS. If you want to use non-core "Error" module, you need to install it. Do "ppm install Error". Also, you can use similar modules Try::Tiny and TryCatch. They are non-core too, so you also would need to inst
Q&A Tutorials Poetry RecentThreads NewestNodes Donate What'sNew on Jul 28, 2003 at 21:09UTC ( #278619=perlquestion: print w/replies, xml ) Need Help?? cleverett has asked for the wisdom of the Perl Monks concerning the following question: Hi, I'm looking for modules that use the Error modules, so I http://www.perlmonks.org/?node_id=278619 can learn how to use it. The perldocs for it leave me a bit mystified. Though I have all kinds of modules on my system installed via CPAN, the only one that I grep out "use Error" from https://foswiki.org/Tasks/Item13519 is DBI, and all it does with it is a single line "use Error;". Comment on Learning how to use the Error module by exampleDownload Code Replies are listed 'Best First'. Re: Learning how to use the perl error Error module by example by perrin (Chancellor) on Jul 28, 2003 at 21:14UTC I recommend that you don't use the try/catch syntax of the Error module. It can lead to some difficult bugs involving closures and returns that don't actually return.[reply] Re2: Learning how to use the Error module by example by dragonchild (Archbishop) on Jul 29, 2003 at 12:31UTC Please provide an example of where this situation occurs. If I didn't know you better, error.pm perl module perrin, I would say that your statement is one of an ex-Java programmer waving his hands cause the try-catch syntax in Error reminds him of dark days in the past. :-) ------We are the carpenters and bricklayers of the Information Age.Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.[reply] Re: Re2: Learning how to use the Error module by example by perrin (Chancellor) on Jul 29, 2003 at 17:38UTC I wouldn't just go spreading FUD abour Error.pm. It has very serious problems, and the only reason I didn't describe them is that I thought they were well-known. The try/catch syntax is implemented using sub ref prototypes. Take a look at this code: use Error qw( :try ); sub important_function { try { something_dangerous(); } catch Error::Simple with { return 0; }; return 1; } [download] What value do you think this sub will return if it catches an error? It will always return 1, because the return inside of the catch block just returns from the implicit subroutine that the catch block creates. Nasty. Possibly worse, the nested closure problem can cause memory leaks in a long-running process. The problem is partially described by Matts in this pre
Blog Extensions Documentation Community Development Tasks Download Support You are here: Foswiki>Tasks Web>Item13519 (16 Nov 2015, GeorgeClark)Edit Attach Item13519: Foswiki should clearly report missing dependencies. Don't crash with 500 Internal Server Error. Priority: Urgent Current State: Closed Released In: 2.0.3 Target Release: patch Applies To: Engine Component: Configure Branches: master Reported By: ThanJay Waiting For: Last Change By: GeorgeClark Original report: "Configuration page was not coming after did all set up for foswiki 2.0. Throws error as Can't locate Error.pm in @INC (you may need to install the Error module)" -- ThanJay - 11 Jul 2015 This error am getting. Apache version: 2.2 Active Perl : 5.20 Can't locate Error.pm in @INC (you may need to install the Error module) (@INC contains: C:/foswiki20/lib C:/Perl/site/lib C:/Perl/lib . C:/foswiki20/lib/CPAN/lib) at C:/foswiki20/lib/Foswiki.pm line 48. at C:/foswiki20/lib/Foswiki.pm line 48. Foswiki::BEGIN() called at C:/foswiki20/lib/Foswiki.pm line 48 eval {...} called at C:/foswiki20/lib/Foswiki.pm line 48 require Foswiki.pm called at C:/foswiki20/bin/configure line 27 main::BEGIN() called at C:/foswiki20/lib/Foswiki.pm line 48 eval {...} called at C:/foswiki20/lib/Foswiki.pm line 48 BEGIN failed--compilation aborted at C:/foswiki20/lib/Foswiki.pm line 48. at C:/foswiki20/lib/Foswiki.pm line 48. require Foswiki.pm called at C:/foswiki20/bin/configure line 27 main::BEGIN() called at C:/foswiki20/lib/Foswiki.pm line 48 eval {...} called at C:/foswiki20/lib/Foswiki.pm line 48 Compilation failed in require at C:/foswiki20/bin/configure line 27. at C:/foswiki20/bin/configure line 27. main::BEGIN() called at C:/foswiki20/bin/configure line 27 eval {...} called at C:/foswiki20/bin/configure line 27 BEGIN failed--compilation aborted at C:/foswiki20/bin/configure line 27. at