{
    "mode": "perldoc",
    "parameter": "Template::Exception",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Template%3A%3AException/json",
    "generated": "2026-07-05T13:31:58Z",
    "synopsis": "use Template::Exception;\nmy $exception = Template::Exception->new($type, $info);\n$type = $exception->type;\n$info = $exception->info;\n($type, $info) = $exception->typeinfo;\nprint $exception->asstring();\n$handler = $exception->selecthandler(\\@candidates);",
    "sections": {
        "NAME": {
            "content": "Template::Exception - Exception handling class module\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Template::Exception;\n\nmy $exception = Template::Exception->new($type, $info);\n$type = $exception->type;\n$info = $exception->info;\n($type, $info) = $exception->typeinfo;\n\nprint $exception->asstring();\n\n$handler = $exception->selecthandler(\\@candidates);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "The \"Template::Exception\" module defines an object class for representing exceptions within the\ntemplate processing life cycle. Exceptions can be raised by modules within the Template Toolkit,\nor can be generated and returned by user code bound to template variables.\n\nExceptions can be raised in a template using the \"THROW\" directive,\n\n[% THROW user.login 'no user id: please login' %]\n\nor by calling the throw() method on the current Template::Context object,\n\n$context->throw('user.passwd', 'Incorrect Password');\n$context->throw('Incorrect Password');    # type 'undef'\n\nor from Perl code by calling \"die()\" with a \"Template::Exception\" object,\n\ndie (Template::Exception->new('user.denied', 'Invalid User ID'));\n\nor by simply calling \"die()\" with an error string. This is automagically caught and converted to\nan exception of '\"undef\"' type (that's the literal string '\"undef\"' rather than Perl's undefined\nvalue) which can then be handled in the usual way.\n\ndie \"I'm sorry Dave, I can't do that\";\n\nEach exception is defined by its type and a information component (e.g. error message). The type\ncan be any identifying string and may contain dotted components (e.g. '\"foo\"', '\"foo.bar\"',\n'\"foo.bar.baz\"'). Exception types are considered to be hierarchical such that '\"foo.bar\"' would\nbe a specific type of the more general '\"foo\"' type.\n",
            "subsections": []
        },
        "METHODS": {
            "content": "type()\nReturns the exception type.\n\ninfo()\nReturns the exception information.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Andy Wardley <abw@wardley.org> <http://wardley.org/>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.\n\nThis module is free software; you can redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "Template, Template::Context\n",
            "subsections": []
        }
    },
    "summary": "Template::Exception - Exception handling class module",
    "flags": [],
    "examples": [],
    "see_also": []
}