Exception::Class::TCF

Exception::Class::TCF is a Java/C style exception handling.
Download

Exception::Class::TCF Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Torsten Ekedahl
  • Publisher web site:
  • http://search.cpan.org/~rvosa/Exception-Class-TCF-0.03/lib/Exception/Class/TCF.pm

Exception::Class::TCF Tags


Exception::Class::TCF Description

Exception::Class::TCF is a Java/C style exception handling. Exception::Class::TCF is a Java/C style exception handling.SYNOPSIStry BLOCK NAME FUN_REF ]*throw package EnclosureException; @ISA = qw(Exception::Class::TCF); package main; use Exception::Class::TCF; try { if ($Lost) { throw new EnclosureException Message => "Help!"; } else { throw Error; } } catch 'EnclosureException' => sub { warn "Message ",$_->message," received.n" }, 'Default' => sub { warn $_->type, " exception ignored, trace:", $_->trace };The Exception::Class::TCF module provides the possibility of executing a code block and specifying actions when different exceptions are raised. The try function takes as its argument a code block followed by a list of pairs of exception package names and function references, representing the action to take if a subclass of that package is raised. To increase readability the keyword catch may be inserted before any name-action pair. The return value of try is the return value of the block if no exception is thrown and the return value of the action of the chosen action in case one is found.Even though the builtin die is used in the implementation any explicit use of die within the dynamic scope is ignored by the exception mechanism and thus works as usual. On the other hand an eval block will catch a thrown exception if it has not been caught by a try block. The clean-up routines after such a block may call throw as in the next section.How to create an exception context.An exception context in which thrown exceptions are handled is created using try as in try { throw 'Error' } catch 'Default' => sub { warn "Wow" };The first argument is a code block (or a function reference). It will be referred to as a try block and any code executed inside it (including psossibly nested calls of functions in it) will be said to be in the dynamic scope of the block. After the try block follows a sequence of exception name - handling code pairs. The name will be referred to as the exception key and the corresponding code the handler (or catch handler) for that key.An exception is either the name of a package inheriting from the package Exception::Class::TCF or an object blessed in such a package. In both cases the name of the package will be referred to as the name of the exception. All exception keys has to be names of exceptions except the special exception key Default which is the name for exceptions of package Exception::Class::TCF. In order not to clutter package name space, package names are normally prefixed by the Exception::Class::TCF:: prefix. To increase readability this prefix may be removed in exception key names and when calling throw with a package name as first argument.The exception key may also be the string Finally. This does not correspond to an exception but instead its handler will be called just before the try function returns. Its value will be ignored however.As new is a virtual function it can not be called with these shortened package names. For this on can use Exception::Class::TCF::make instead. Requirements: · Perl


Exception::Class::TCF Related Software