File: Exceptions.html

package info (click to toggle)
libhtml-mason-perl 1%3A1.39-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,072 kB
  • ctags: 1,535
  • sloc: perl: 17,624; sh: 187; makefile: 12
file content (248 lines) | stat: -rw-r--r-- 7,938 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML::Mason::Exceptions - Exception objects thrown by Mason</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rev="made" href="mailto:root@localhost" />
</head>

<body style="background-color: white">

<p><A NAME="__index__"></a></p>
<!-- INDEX BEGIN -->

<ul>

	<li><A HREF="#name">NAME</a></li>
	<li><A HREF="#synopsis">SYNOPSIS</a></li>
	<li><A HREF="#description">DESCRIPTION</a></li>
	<li><A HREF="#import">IMPORT</a></li>
	<li><A HREF="#exceptions">EXCEPTIONS</a></li>
	<li><A HREF="#fields">FIELDS</a></li>
	<li><A HREF="#exception_methods">EXCEPTION METHODS</a></li>
	<li><A HREF="#exception_class_checking">EXCEPTION CLASS CHECKING</a></li>
</ul>
<!-- INDEX END -->

<hr />
<p>
</p>
<h1><A NAME="name">NAME</a></h1>
<p>HTML::Mason::Exceptions - Exception objects thrown by Mason</p>
<p>
</p>
<hr />
<h1><A NAME="synopsis">SYNOPSIS</a></h1>
<pre>
  use HTML::Mason::Exceptions ( abbr =&gt; [ qw(system_error) ] );</pre>
<pre>
  open FH, 'foo' or system_error &quot;cannot open foo: $!&quot;;</pre>
<p>
</p>
<hr />
<h1><A NAME="description">DESCRIPTION</a></h1>
<p>This module creates the hierarchy of exception objects used by Mason,
and provides some extra methods for them beyond those provided by
<code>Exception::Class</code></p>
<p>
</p>
<hr />
<h1><A NAME="import">IMPORT</a></h1>
<p>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 <A HREF="#synopsis">SYNOPSIS</a> example, we use the <code>system_error</code>
function to throw a <A HREF="#item_html_3a_3amason_3a_3aexcept"><code>HTML::Mason::Exception::System</code></a> exception.</p>
<p>These abbreviated functions do not allow you to set additional fields
in the exception, only the message.</p>
<p>
</p>
<hr />
<h1><A NAME="exceptions">EXCEPTIONS</a></h1>
<dl>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception</a></strong>

<dd>
<p>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.</p>
</dd>
<dd>
<p>Abbreviated as <code>error</code></p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::Abort</a></strong>

<dd>
<p>The <code>$m-&gt;abort</code> method was called.</p>
</dd>
<dd>
<p>Exceptions in this class contain the field <code>aborted_value</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::Decline</a></strong>

<dd>
<p>The <code>$m-&gt;decline</code> method was called.</p>
</dd>
<dd>
<p>Exceptions in this class contain the field <code>declined_value</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::Compilation</a></strong>

<dd>
<p>An exception occurred when attempting to <code>eval</code> an existing object
file.</p>
</dd>
<dd>
<p>Exceptions in this class have the field <code>filename</code>, which indicates
what file contained the code that caused the error.</p>
</dd>
<dd>
<p>Abbreviated as <code>compilation_error</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::Compiler</a></strong>

<dd>
<p>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.</p>
</dd>
<dd>
<p>Abbreviated as <code>compiler_error</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::Compilation::IncompatibleCompiler</a></strong>

<dd>
<p>A component was compiled by a compiler or lexer with incompatible
options.  This is used to tell Mason to recompile a component.</p>
</dd>
<dd>
<p>Abbreviated as <code>wrong_compiler_error</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::Params</a></strong>

<dd>
<p>Invalid parameters were passed to a method or function.</p>
</dd>
<dd>
<p>Abbreviated as <code>param_error</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::Syntax</a></strong>

<dd>
<p>This exception indicates that a component contained invalid syntax.</p>
</dd>
<dd>
<p>Exceptions in this class have the fields <code>source_line</code>, which is the
actual source where the error was found, <code>comp_name</code>, and
<code>line_number</code>.</p>
</dd>
<dd>
<p>Abbreviated as <code>syntax_error</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::System</a></strong>

<dd>
<p>A system call of some sort, such as a file open, failed.</p>
</dd>
<dd>
<p>Abbreviated as <code>system_error</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3aexcept">HTML::Mason::Exception::TopLevelNotFound</a></strong>

<dd>
<p>The requested top level component could not be found.</p>
</dd>
<dd>
<p>Abbreviated as <code>top_level_not_found_error</code>.</p>
</dd>
</li>
<dt><strong><A NAME="item_html_3a_3amason_3a_3avirtua">HTML::Mason::VirtualMethod</a></strong>

<dd>
<p>Some piece of code attempted to call a virtual method which was not
overridden.</p>
</dd>
<dd>
<p>Abbreviated as <code>virtual_error</code></p>
</dd>
</li>
</dl>
<p>
</p>
<hr />
<h1><A NAME="fields">FIELDS</a></h1>
<p>Some of the exceptions mentioned above have additional fields, which
are available via accessors.  For example, to get the line number of
an <A HREF="#item_html_3a_3amason_3a_3aexcept"><code>HTML::Mason::Exception::Syntax</code></a> exception, you call the
<code>line_number</code> method on the exception object.</p>
<p>
</p>
<hr />
<h1><A NAME="exception_methods">EXCEPTION METHODS</a></h1>
<p>All of the Mason exceptions implement the following methods:</p>
<dl>
<dt><strong><A NAME="item_as_brief">as_brief</a></strong>

<dd>
<p>This simply returns the exception message, without any trace information.</p>
</dd>
</li>
<dt><strong><A NAME="item_as_line">as_line</a></strong>

<dd>
<p>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.</p>
</dd>
</li>
<dt><strong><A NAME="item_as_text">as_text</a></strong>

<dd>
<p>This returns the exception message and stack information, with each
frame on a separate line.</p>
</dd>
</li>
<dt><strong><A NAME="item_as_html">as_html</a></strong>

<dd>
<p>This returns the exception message and stack as an HTML page.</p>
</dd>
</li>
</dl>
<p>Each of these methods corresponds to a valid error_format parameter
for the <a HREF="Request.html">Request object</a> such as <code>text</code> or
<code>html</code>.</p>
<p>You can create your own method in the <A HREF="#item_html_3a_3amason_3a_3aexcept"><code>HTML::Mason::Exception</code></a>
namespace, such as <code>as_you_wish</code>, 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.</p>
<p>
</p>
<hr />
<h1><A NAME="exception_class_checking">EXCEPTION CLASS CHECKING</a></h1>
<p>This module also exports the <code>isa_mason_exception</code> function.  This
function takes the exception object and an optional string parameter
indicating what subclass to check for.</p>
<p>So it can be called either as:</p>
<pre>
  if ( isa_mason_exception($@) ) { ... }</pre>
<p>or</p>
<pre>
  if ( isa_mason_exception($@, 'Syntax') ) { ... }</pre>
<p>Note that when specifying a subclass you should not include the
leading ``HTML::Mason::Exception::'' portion of the class name.</p>

</body>

</html>