{
    "mode": "perldoc",
    "parameter": "HTML::Mason::Exceptions",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/HTML%3A%3AMason%3A%3AExceptions/json",
    "generated": "2026-06-13T00:59:55Z",
    "synopsis": "use HTML::Mason::Exceptions ( abbr => [ qw(systemerror) ] );\nopen FH, 'foo' or systemerror \"cannot open foo: $!\";",
    "sections": {
        "NAME": {
            "content": "HTML::Mason::Exceptions - Exception objects thrown by Mason\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use HTML::Mason::Exceptions ( abbr => [ qw(systemerror) ] );\n\nopen FH, 'foo' or systemerror \"cannot open foo: $!\";\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "This module creates the hierarchy of exception objects used by Mason, and provides some extra\nmethods for them beyond those provided by \"Exception::Class\"\n",
            "subsections": []
        },
        "IMPORT": {
            "content": "When this module is imported, it is possible to specify a list of abbreviated function names\nthat you want to use to throw exceptions. In the SYNOPSIS example, we use the \"systemerror\"\nfunction to throw a \"HTML::Mason::Exception::System\" exception.\n\nThese abbreviated functions do not allow you to set additional fields in the exception, only the\nmessage.\n",
            "subsections": []
        },
        "EXCEPTIONS": {
            "content": "HTML::Mason::Exception\nThis is the parent class for all exceptions thrown by Mason. Mason sometimes throws\nexceptions in this class when we could not find a better category for the message.\n\nAbbreviated as \"error\"\n\nHTML::Mason::Exception::Abort\nThe \"$m->abort\" method was called.\n\nExceptions in this class contain the field \"abortedvalue\".\n\nHTML::Mason::Exception::Decline\nThe \"$m->decline\" method was called.\n\nExceptions in this class contain the field \"declinedvalue\".\n\nHTML::Mason::Exception::Compilation\nAn exception occurred when attempting to \"eval\" an existing object file.\n\nExceptions in this class have the field \"filename\", which indicates what file contained the\ncode that caused the error.\n\nAbbreviated as \"compilationerror\".\n\nHTML::Mason::Exception::Compiler\nThe compiler threw an exception because it received incorrect input. For example, this would\nbe thrown if the lexer told the compiler to initialize compilation while it was in the\nmiddle of compiling another component.\n\nAbbreviated as \"compilererror\".\n\nHTML::Mason::Exception::Compilation::IncompatibleCompiler\nA component was compiled by a compiler or lexer with incompatible options. This is used to\ntell Mason to recompile a component.\n\nAbbreviated as \"wrongcompilererror\".\n\nHTML::Mason::Exception::Params\nInvalid parameters were passed to a method or function.\n\nAbbreviated as \"paramerror\".\n\nHTML::Mason::Exception::Syntax\nThis exception indicates that a component contained invalid syntax.\n\nExceptions in this class have the fields \"sourceline\", which is the actual source where the\nerror was found, \"compname\", and \"linenumber\".\n\nAbbreviated as \"syntaxerror\".\n\nHTML::Mason::Exception::System\nA system call of some sort, such as a file open, failed.\n\nAbbreviated as \"systemerror\".\n\nHTML::Mason::Exception::TopLevelNotFound\nThe requested top level component could not be found.\n\nAbbreviated as \"toplevelnotfounderror\".\n\nHTML::Mason::VirtualMethod\nSome piece of code attempted to call a virtual method which was not overridden.\n\nAbbreviated as \"virtualerror\"\n",
            "subsections": []
        },
        "FIELDS": {
            "content": "Some of the exceptions mentioned above have additional fields, which are available via\naccessors. For example, to get the line number of an \"HTML::Mason::Exception::Syntax\" exception,\nyou call the \"linenumber\" method on the exception object.\n",
            "subsections": []
        },
        "EXCEPTION METHODS": {
            "content": "All of the Mason exceptions implement the following methods:\n\nasbrief\nThis simply returns the exception message, without any trace information.\n\nasline\nThis returns the exception message and its trace information, all on a single line with tabs\nbetween the message and each frame of the stack trace.\n\nastext\nThis returns the exception message and stack information, with each frame on a separate\nline.\n\nashtml\nThis returns the exception message and stack as an HTML page.\n\nEach of these methods corresponds to a valid errorformat parameter for the Request object such\nas \"text\" or \"html\".\n\nYou can create your own method in the \"HTML::Mason::Exception\" namespace, such as \"asyouwish\",\nin which case you could set this parameter to \"youwish\". This method will receive a single\nargument, the exception object, and is expected to return some sort of string containing the\nformatted error message.\n",
            "subsections": []
        },
        "EXCEPTION CLASS CHECKING": {
            "content": "This module also exports the \"isamasonexception\" function. This function takes the exception\nobject and an optional string parameter indicating what subclass to check for.\n\nSo it can be called either as:\n\nif ( isamasonexception($@) ) { ... }\n\nor\n\nif ( isamasonexception($@, 'Syntax') ) { ... }\n\nNote that when specifying a subclass you should not include the leading\n\"HTML::Mason::Exception::\" portion of the class name.\n",
            "subsections": []
        }
    },
    "summary": "HTML::Mason::Exceptions - Exception objects thrown by Mason",
    "flags": [],
    "examples": [],
    "see_also": []
}