The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

XML::Template::Exception - XML::Template exception handling class.

SYNOPSIS

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')) { ... }

DESCRIPTION

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 ();

CONSTRUCTOR

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.

isa

  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.

type

  my $type = $exception->type;

This method returns the exception type.

info

  my $info = $exception->info;

This method returns the info associated with the exception.

AUTHOR

Jonathan Waxman jowaxman@bbl.med.upenn.edu

COPYRIGHT

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.