XML::Template::Exception - XML::Template exception handling class.
use XML::Template::Exception;
my $exception = XML::Template::Exception->new ('ERRORTYPE', 'This is the error info.'); my $type = $exception->type; my $info = $exception->info; if ($exception->isa ('DB')) { ... }
This modules provides a class for handing exceptions. Typically exceptions are raised in code generated by Element modules. For instance, here is some exception handling code from the DB Element module:
\$result = \$db->select (Table => \$tables, Where => \$where); die XML::Template::Exception->new ('DB', \$db->error ()) if defined \$db->error ();
The constructor takes two parameters. The first is the error type which a short identifier. The type may contain dotted components (e.g. 'foo', 'foo.bar', 'foo.bar.baz'), so that exception types are hierarchical. That is, 'foo.bar' would be a specific type of the more general 'foo' type. If no type is given, the type is set to 'Undefined'. The second parameter is the text that describes the exception.
The constructor returns a blessed array containg the exception type and info.
if ($exception->isa ('foo.bar')) { ... }
This method returns 1 if the Exception is of the given type. The given type is matched against each full type in the type hierarchy as well as each child in the hierarchy. So, for instance, if the exception type is foo.bar, $exception-isa ('foo.bar')>, $exception-isa ('foo')>, and $exception-isa ('bar')> will all return 1.
foo.bar
$exception-
my $type = $exception->type;
This method returns the exception type.
my $info = $exception->info;
This method returns the info associated with the exception.
Jonathan Waxman jowaxman@bbl.med.upenn.edu
Copyright (c) 2002 Jonathan A. Waxman All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install XML::Template, copy and paste the appropriate command in to your terminal.
cpanm
cpanm XML::Template
CPAN shell
perl -MCPAN -e shell install XML::Template
For more information on module installation, please visit the detailed CPAN module installation guide.