++ed by:
CHANKEY XAV NEILB AYOUNG KEEDI

59 PAUSE users
38 non-PAUSE users.

Andy Wardley

NAME

Template::Exception - exception handling class for the Template Toolkit

SYNOPSIS

    use Template::Exception;

    my $exception = Template::Exception->new($type, $data);

DESCRIPTION

The Template::Exception module defines an object class for representing exceptional conditions (i.e. errors) within the template processing life cycle. Exceptions can be raised by modules within the Template Toolkit, or can be generated and returned by user code bound to template variables.

User code bound to template stash variables is expected to return a single $value or a pair of ($value, $error). The $error code may be a numerical value represented by one of the Template::Constant STATUS_XXXX constants. User code may "throw" an exception to the calling context, or throw the exception type and information fields so that an exception can be constructed. The context will then handle the exception in some way and return a value which can be propogated back to the caller. Depending on the presence of a CATCH for the exception type, that value may be the exception itself or some other status value.

    sub my_code {
        my ($context = shift);
        
        # blah, blah, blah...

        if ($database_has_exploded) {
            return (undef, $context->throw("database", $database_error));
        }
        else {
            return $value;
        }
    }

    $template->process($my_file, { 'magic' => \&my_code })
        || die $template->error(); 

AUTHOR

Andy Wardley <cre.canon.co.uk>

REVISION

$Revision: 1.3 $

COPYRIGHT

Copyright (C) 1996-1999 Andy Wardley. All Rights Reserved. Copyright (C) 1998-1999 Canon Research Centre Europe Ltd.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

Template