Perl Error Simple
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 METHODS PRE-DEFINED ERROR CLASSES Error::Simple $Error::ObjectifyCallback perl error variable MESSAGE HANDLERS EXAMPLE SEE ALSO KNOWN BUGS AUTHORS MAINTAINER PAST MAINTAINERS COPYRIGHT NAME Error
Perl Error Handling
- Error/exception handling in an OO-ish way WARNING Using the "Error" module is no longer recommended due to the black-magical
Perl Catch Error
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
Perl Try
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; print STDERR "File ", $E->{'-file'}, " had a problem\n"; } except { my $E = shift; my $general_handler=sub {send_message $E->{-description}}; perl error code 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 of the block. CLAUSES are the subroutines below, which describe what to do in the event of an error being thrown within BLOCK. catch CLASS with BLOCK This clauses will cause all errors that satisfy $err->isa(CLASS) to be caught an
or shared libraries (libXm.so.2) in standard path. It perl warn does not support multiple arguments yet... The System and Arch are optional added filters, http://search.cpan.org/~shlomif/Error-0.17022/lib/Error.pm for example System could be "redhat", "redhat-7.2", "mandrake" or "gnome", Arch could be "i386" or "src", etc. depending on your system. System Arch RPM resource perl(Error::Simple) Found 216 RPM https://www.rpmfind.net/linux/rpm2html/search.php?query=perl(Error%3A%3ASimple) for perl(Error::Simple) PackageSummaryDistributionDownload git-1.9.1-1.ram0.99.i686.htmlGitSourceForgegit-1.9.1-1.ram0.99.i686.rpmgit-1.9.1-1.ram0.99.x86_64.htmlGitSourceForgegit-1.9.1-1.ram0.99.x86_64.rpmgit-1.8.4.1-1.ram0.98.i686.htmlGitSourceForgegit-1.8.4.1-1.ram0.98.i686.rpmgit-1.8.4.1-1.ram0.98.x86_64.htmlGitSourceForgegit-1.8.4.1-1.ram0.98.x86_64.rpm perl-Bioperl-1.5.0-2mdk.noarch.htmlBioPerl core modulesMandriva 2006.0 for i586perl-Bioperl-1.5.0-2mdk.noarch.rpmperl-Bioperl-1.5.0-2mdk.noarch.htmlBioPerl core modulesMandriva devel 2006.0 for x86_64perl-Bioperl-1.5.0-2mdk.noarch.rpmperl-Bioperl-1.5.0-2mdk.noarch.htmlBioPerl core modulesMandriva 2006.0 for x86_64perl-Bioperl-1.5.0-2mdk.noarch.rpmperl-Bioperl-1.5.0-2mdk.noarch.htmlBioPerl core modulesMandriva devel 2006.0 for i586perl-Bioperl-1.5.0-2mdk.noarch.rpmperl-Bioperl-1.5.0-1mdk.noarch.htmlBioPerl core modulesMandriva 10.2 for i586perl-Bioperl-1.5.0-1mdk.noarch.rpmperl-Bioperl-1.4-3mdk.noarch.htmlBioPerl core modulesMandriva 10.1 for i586perl-Bioperl-1.4-3mdk.noarch.rpmperl-Bioperl-1.4-2mdk.noarch.htmlBioPerl core modulesMandriva devel cooker for ia64perl-Bioperl-1.4-2mdk.noarch.rpm perl-Error-0.17024-7.fc25.noarch.htmlError/exception handling in an OO-ish wayFedora Rawhide for armhfpperl-Error-0.17024-7.fc25.noarch.rpmperl-Error-0.17024-7.fc25.noarch.htmlError/exception handling in an OO-ish wayFedora Rawhide for ppc64leperl-Error-0.17024-7.fc25.noarch.rpmperl-Error-0.17024-7.fc25.noarch.htmlError/exception handling in an OO-ish wayFedora Rawhide for x86_64perl-Error-0.17024-7.fc25.noarch.rpmperl-Error-0.17024-7.fc25.noarch.htmlError/exception handling in an OO-ish wayFedora Rawhide for aarch64perl-Error-0.17024-7.fc25.noarch.rpmperl-Error-0.17024-7.fc25.noarch.htmlError/exception handling in an OO-ish wayFedora Rawhide for s390xperl-Error-0.17024-7.fc25.noarch.rpmperl-Error-0.17024-7.fc25.noar
A • B • C • D • E F • G • H http://perldoc.perl.org/5.12.1/Log/Message/Simple.html • I • L M • N • O • P • S T • U • X Log::Message::Simple Perl 5 http://lwp.interglacial.com/ch02_03.htm version 12.1 documentation Go to top • Download PDF Show page index • Show recent pages Home > Core modules (L) perl error > Log::Message::Simple Please note: Many features of this site require JavaScript. You appear to have JavaScript disabled, or are running a non-JavaScript capable web browser. To get the best experience, please enable JavaScript or download a modern web browser such as Internet Explorer perl error simple 8, Firefox, Safari, or Google Chrome. Recently read Log::Message::Simple NAMESYNOPSISDESCRIPTIONFUNCTIONSmsg("message string" [,VERBOSE])debug("message string" [,VERBOSE])error("error string" [,VERBOSE])carp();croak();confess();cluck();CLASS METHODSLog::Message::Simple->stack()Log::Message::Simple->stack_as_string([TRACE])Log::Message::Simple->flush()GLOBAL VARIABLESNAME Log::Message::Simple - Simplified interface to Log::Message SYNOPSIS use Log::Message::Simple qw[msg error debug carp croak cluck confess]; use Log::Message::Simple qw[:STD :CARP]; ### standard reporting functionality msg( "Connecting to database", $verbose ); error( "Database connection failed: $@", $verbose ); debug( "Connection arguments were: $args", $debug ); ### standard carp functionality carp( "Wrong arguments passed: @_" ); croak( "Fatal: wrong arguments passed: @_" ); cluck( "Wrong arguments passed -- including stacktrace: @_" ); confess("Fatal: wrong arguments passed -- including stacktrace: @_" ); ### retrieve individual message my @stack = Log::Message::Simple->stack; my @stack = Log::Message::Simple->flush; ### retrieve the entire stack in printable form my $msgs = Log::Message::Simple->stack_as_string; my $trace = Log::Message::S
a document with a GET request. Some functions return the document, others save or print the document. 2.3.1. Basic Document Fetch The LWP::Simple module's get() function takes a URL and returns the body of the document: $document = get("http://www.suck.com/daily/2001/01/05/1.html"); If the document can't be fetched, get( ) returns undef. Incidentally, if LWP requests that URL and the server replies that it has moved to some other URL, LWP requests that other URL and returns that. With LWP::Simple's get() function, there's no way to set headers to be sent with the GET request or get more information about the response, such as the status code. These are important things, because some web servers have copies of documents in different languages and use the HTTP language header to determine which document to return. Likewise, the HTTP response code can let us distinguish between permanent failures (e.g., "404 Not Found") and temporary failures ("505 Service [Temporarily] Unavailable"). Even the most common type of nontrivial web robot (a link checker), benefits from access to response codes. A 403 ("Forbidden," usually because of file permissions) could be automatically corrected, whereas a 404 ("Not Found") error implies an out-of-date link that requires fixing. But if you want access to these codes or other parts of the response besides just the main content, your task is no longer a simple one, and so you shouldn't use LWP::Simple for it. The "simple" in LWP::Simple refers not just to the style of its interface, but also to the kind of tasks for which it's meant. 2.3.2. Fetch and Store One way to get the status code is to use LWP::Simple's getstore() function, which writes the document to a file and returns the status code from the response: $status = getstore("http://www.suck.com/daily/2001/01/05/1.html", "/tmp/web.html"); There are two problems with this. The first is that the document is now stored in a file instead of in a variable where you can process it (extract information, convert to another format, etc.). This is readily solved by reading the file using Perl's built-in open() and