.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "HTML::Mason::Exceptions 3pm" .TH HTML::Mason::Exceptions 3pm 2024-03-05 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME HTML::Mason::Exceptions \- Exception objects thrown by Mason .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use HTML::Mason::Exceptions ( abbr => [ qw(system_error) ] ); \& \& open FH, \*(Aqfoo\*(Aq or system_error "cannot open foo: $!"; .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" This module creates the hierarchy of exception objects used by Mason, and provides some extra methods for them beyond those provided by \&\f(CW\*(C`Exception::Class\*(C'\fR .SH IMPORT .IX Header "IMPORT" When this module is imported, it is possible to specify a list of abbreviated function names that you want to use to throw exceptions. In the SYNOPSIS example, we use the \f(CW\*(C`system_error\*(C'\fR function to throw a \f(CW\*(C`HTML::Mason::Exception::System\*(C'\fR exception. .PP These abbreviated functions do not allow you to set additional fields in the exception, only the message. .SH EXCEPTIONS .IX Header "EXCEPTIONS" .IP HTML::Mason::Exception 4 .IX Item "HTML::Mason::Exception" This is the parent class for all exceptions thrown by Mason. Mason sometimes throws exceptions in this class when we could not find a better category for the message. .Sp Abbreviated as \f(CW\*(C`error\*(C'\fR .IP HTML::Mason::Exception::Abort 4 .IX Item "HTML::Mason::Exception::Abort" The \f(CW\*(C`$m\->abort\*(C'\fR method was called. .Sp Exceptions in this class contain the field \f(CW\*(C`aborted_value\*(C'\fR. .IP HTML::Mason::Exception::Decline 4 .IX Item "HTML::Mason::Exception::Decline" The \f(CW\*(C`$m\->decline\*(C'\fR method was called. .Sp Exceptions in this class contain the field \f(CW\*(C`declined_value\*(C'\fR. .IP HTML::Mason::Exception::Compilation 4 .IX Item "HTML::Mason::Exception::Compilation" An exception occurred when attempting to \f(CW\*(C`eval\*(C'\fR an existing object file. .Sp Exceptions in this class have the field \f(CW\*(C`filename\*(C'\fR, which indicates what file contained the code that caused the error. .Sp Abbreviated as \f(CW\*(C`compilation_error\*(C'\fR. .IP HTML::Mason::Exception::Compiler 4 .IX Item "HTML::Mason::Exception::Compiler" The compiler threw an exception because it received incorrect input. For example, this would be thrown if the lexer told the compiler to initialize compilation while it was in the middle of compiling another component. .Sp Abbreviated as \f(CW\*(C`compiler_error\*(C'\fR. .IP HTML::Mason::Exception::Compilation::IncompatibleCompiler 4 .IX Item "HTML::Mason::Exception::Compilation::IncompatibleCompiler" A component was compiled by a compiler or lexer with incompatible options. This is used to tell Mason to recompile a component. .Sp Abbreviated as \f(CW\*(C`wrong_compiler_error\*(C'\fR. .IP HTML::Mason::Exception::Params 4 .IX Item "HTML::Mason::Exception::Params" Invalid parameters were passed to a method or function. .Sp Abbreviated as \f(CW\*(C`param_error\*(C'\fR. .IP HTML::Mason::Exception::Syntax 4 .IX Item "HTML::Mason::Exception::Syntax" This exception indicates that a component contained invalid syntax. .Sp Exceptions in this class have the fields \f(CW\*(C`source_line\*(C'\fR, which is the actual source where the error was found, \f(CW\*(C`comp_name\*(C'\fR, and \&\f(CW\*(C`line_number\*(C'\fR. .Sp Abbreviated as \f(CW\*(C`syntax_error\*(C'\fR. .IP HTML::Mason::Exception::System 4 .IX Item "HTML::Mason::Exception::System" A system call of some sort, such as a file open, failed. .Sp Abbreviated as \f(CW\*(C`system_error\*(C'\fR. .IP HTML::Mason::Exception::TopLevelNotFound 4 .IX Item "HTML::Mason::Exception::TopLevelNotFound" The requested top level component could not be found. .Sp Abbreviated as \f(CW\*(C`top_level_not_found_error\*(C'\fR. .IP HTML::Mason::VirtualMethod 4 .IX Item "HTML::Mason::VirtualMethod" Some piece of code attempted to call a virtual method which was not overridden. .Sp Abbreviated as \f(CW\*(C`virtual_error\*(C'\fR .SH FIELDS .IX Header "FIELDS" Some of the exceptions mentioned above have additional fields, which are available via accessors. For example, to get the line number of an \f(CW\*(C`HTML::Mason::Exception::Syntax\*(C'\fR exception, you call the \&\f(CW\*(C`line_number\*(C'\fR method on the exception object. .SH "EXCEPTION METHODS" .IX Header "EXCEPTION METHODS" All of the Mason exceptions implement the following methods: .IP as_brief 4 .IX Item "as_brief" This simply returns the exception message, without any trace information. .IP as_line 4 .IX Item "as_line" This returns the exception message and its trace information, all on a single line with tabs between the message and each frame of the stack trace. .IP as_text 4 .IX Item "as_text" This returns the exception message and stack information, with each frame on a separate line. .IP as_html 4 .IX Item "as_html" This returns the exception message and stack as an HTML page. .PP Each of these methods corresponds to a valid error_format parameter for the Request object such as \f(CW\*(C`text\*(C'\fR or \&\f(CW\*(C`html\*(C'\fR. .PP You can create your own method in the \f(CW\*(C`HTML::Mason::Exception\*(C'\fR namespace, such as \f(CW\*(C`as_you_wish\*(C'\fR, in which case you could set this parameter to "you_wish". This method will receive a single argument, the exception object, and is expected to return some sort of string containing the formatted error message. .SH "EXCEPTION CLASS CHECKING" .IX Header "EXCEPTION CLASS CHECKING" This module also exports the \f(CW\*(C`isa_mason_exception\*(C'\fR function. This function takes the exception object and an optional string parameter indicating what subclass to check for. .PP So it can be called either as: .PP .Vb 1 \& if ( isa_mason_exception($@) ) { ... } .Ve .PP or .PP .Vb 1 \& if ( isa_mason_exception($@, \*(AqSyntax\*(Aq) ) { ... } .Ve .PP Note that when specifying a subclass you should not include the leading "HTML::Mason::Exception::" portion of the class name.