~ubuntu-branches/ubuntu/quantal/libtemplate-perl/quantal

« back to all changes in this revision

Viewing changes to html/old/modules/Template/Exception.html

  • Committer: Package Import Robot
  • Author(s): Benjamin Mako Hill
  • Date: 2012-04-08 19:06:29 UTC
  • mfrom: (0.7.1) (0.5.2) (5.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20120408190629-wbcbs2ea39mex6lt
Tags: 2.24-1
* New upstream release (Closes: #664561)
* Bump Standards-Version to 3.9.3
* Changed to the short description to mention the term "Template
  Toolkit". (LP: #688836)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN">
 
4
<html>
 
5
  <head>
 
6
    <title>Template::Exception</title>
 
7
    <link rel="stylesheet" type="text/css" href="../../css/blue.css" title="Clear Blue">
 
8
    <link rel="alternate stylesheet" type="text/css" href="../../css/orange.css" title="Clear Orange">
 
9
    <link rel="alternate stylesheet" type="text/css" href="../../css/green.css" title="Clear Green">
 
10
    <link rel="alternate stylesheet" type="text/css" href="../../css/purple.css" title="Clear Purple">
 
11
    <link rel="alternate stylesheet" type="text/css" href="../../css/grey.css" title="Clear Grey">
 
12
    <!--[if IE 6]>
 
13
    <link rel="stylesheet" type="text/css" href="../../css/ie6.css" />
 
14
    <![endif]-->
 
15
    <link rel="stylesheet" type="text/css" href="/css/print.css" media="print">
 
16
    <script type="text/javascript" src="../../js/tt2.js"></script>
 
17
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
 
18
    <meta name="author" content="Andy Wardley">
 
19
  </head>
 
20
  <body id="body"> 
 
21
    <div id="layout">
 
22
        <div id="header">
 
23
          <a href="../../index.html" id="logo" alt="" title="Click for the Home Page"><span class="alt">TT2 Home Page</span></a>
 
24
          <ul id="trail">
 
25
            <li><a href="../../modules/index.html">Modules</a></li>
 
26
            <li><a href="../../modules/Template/index.html">Template::*</a></li>
 
27
            <li class="last"><a href="../../modules/Template/Exception.html">Exception.pm</a></li>
 
28
          </ul>
 
29
          <div class="controls">
 
30
            <a href="#" class="menu show" onclick="widescreen_off(); return false" title="Show Menu">
 
31
              <span class="about">Click to view the menu.  It's very nice.</span>
 
32
            </a>
 
33
            <a href="#" class="menu hide" onclick="widescreen_on();  return false" title="Hide Menu">
 
34
              <span class="about">Click to hide the menu and go all widescreen!</span>
 
35
            </a>
 
36
          
 
37
          <div class="pager">
 
38
            <a href="../../modules/Template/Document.html" title="Template::Document" class="go back">Back<span class="about"><h4>Template::Document</h4>Compiled template document object</span></a>
 
39
            <a href="../../modules/Template/index.html" title="Template::* Modules" class="go up">Up<span class="about"><h4>Template::* Modules</h4></span></a>
 
40
            <a href="../../modules/Template/Filters.html" title="Template::Filters" class="go next">Next<span class="about"><h4>Template::Filters</h4>Post-processing filters for template blocks</span></a>
 
41
          </div>
 
42
          </div>
 
43
          <h1 class="headline">Template::Exception</h1>
 
44
          <h2 class="subhead">Exception handling class module</h1>
 
45
        
 
46
        </div>
 
47
        <div id="page">
 
48
          <div id="sidebar">
 
49
            <a href="../../index.html" id="logo"></a>
 
50
            <div id="menu">
 
51
              <ul class="menu">
 
52
                <li class="l0 first"><a href="../../manual/index.html">Manual</a></li>
 
53
                <li class="l0"><a href="../../modules/index.html" class="warm">Modules</a></li>
 
54
                <li class="l1"><a href="../../modules/Template.html">Template.pm</a></li>
 
55
                <li class="l1"><a href="../../modules/Template/index.html" class="warm">Template::*</a></li>
 
56
                <li class="l2"><a href="../../modules/Template/Base.html">Base.pm</a></li>
 
57
                <li class="l2"><a href="../../modules/Template/Config.html">Config.pm</a></li>
 
58
                <li class="l2"><a href="../../modules/Template/Constants.html">Constants.pm</a></li>
 
59
                <li class="l2"><a href="../../modules/Template/Context.html">Context.pm</a></li>
 
60
                <li class="l2"><a href="../../modules/Template/Directive.html">Directive.pm</a></li>
 
61
                <li class="l2"><a href="../../modules/Template/Document.html">Document.pm</a></li>
 
62
                <li class="l2"><a href="../../modules/Template/Exception.html" class="warm">Exception.pm</a></li>
 
63
                <li class="l2"><a href="../../modules/Template/Filters.html">Filters.pm</a></li>
 
64
                <li class="l2"><a href="../../modules/Template/Grammar.html">Grammar.pm</a></li>
 
65
                <li class="l2"><a href="../../modules/Template/Iterator.html">Iterator.pm</a></li>
 
66
                <li class="l2"><a href="../../modules/Template/Namespace/index.html">Namespace::*</a></li>
 
67
                <li class="l2"><a href="../../modules/Template/Parser.html">Parser.pm</a></li>
 
68
                <li class="l2"><a href="../../modules/Template/Plugin.html">Plugin.pm</a></li>
 
69
                <li class="l2"><a href="../../modules/Template/Plugin/index.html">Plugin::*</a></li>
 
70
                <li class="l2"><a href="../../modules/Template/Plugins.html">Plugins.pm</a></li>
 
71
                <li class="l2"><a href="../../modules/Template/Provider.html">Provider.pm</a></li>
 
72
                <li class="l2"><a href="../../modules/Template/Service.html">Service.pm</a></li>
 
73
                <li class="l2"><a href="../../modules/Template/Stash.html">Stash.pm</a></li>
 
74
                <li class="l2"><a href="../../modules/Template/Stash/index.html">Stash::*</a></li>
 
75
                <li class="l2"><a href="../../modules/Template/Test.html">Test.pm</a></li>
 
76
                <li class="l2"><a href="../../modules/Template/VMethods.html">VMethods.pm</a></li>
 
77
                <li class="l2"><a href="../../modules/Template/View.html">View.pm</a></li>
 
78
                <li class="l0"><a href="../../tools/index.html">Tools</a></li>
 
79
                <li class="l0 last"><a href="../../tutorial/index.html">Tutorial</a></li>
 
80
              </ul>
 
81
              <div class="foot"></div>
 
82
            </div>
 
83
          </div>
 
84
          <div id="content">
 
85
          <div class="section">
 
86
            <div class="head">
 
87
              <h1 id="contents" onclick="switch_section(this)" title="Click title to show/hide section content.">Contents</h1>
 
88
              <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
89
            </div>
 
90
            <div class="body">
 
91
              <ul class="toc">
 
92
                  <li class=""><a href="#SYNOPSIS">SYNOPSIS</a></li>
 
93
                  <li class=""><a href="#DESCRIPTION">DESCRIPTION</a></li>
 
94
                  <li class=""><a href="#METHODS">METHODS</a></li>
 
95
                  <li class="sub"><a href="#method_type">type()</a></li>
 
96
                  <li class="sub"><a href="#method_info">info()</a></li>
 
97
                  <li class=""><a href="#AUTHOR">AUTHOR</a></li>
 
98
                  <li class=""><a href="#COPYRIGHT">COPYRIGHT</a></li>
 
99
                  <li class=""><a href="#SEE_ALSO">SEE ALSO</a></li>
 
100
              
 
101
              </ul>
 
102
            </div>
 
103
          </div>
 
104
          
 
105
                <div class="pod">
 
106
            <div class="section">
 
107
              <div class="head">
 
108
                <h1 id="SYNOPSIS" onclick="switch_section(this)" title="Click title to show/hide section content.">SYNOPSIS</h1>
 
109
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
110
              </div>
 
111
              <div class="body">
 
112
                <pre>use Template::Exception;
 
113
 
 
114
my $exception = Template::Exception-&gt;new($type, $info);
 
115
$type = $exception-&gt;type;
 
116
$info = $exception-&gt;info;
 
117
($type, $info) = $exception-&gt;type_info;
 
118
 
 
119
print $exception-&gt;as_string();
 
120
 
 
121
$handler = $exception-&gt;select_handler(\@candidates);</pre>
 
122
              </div>
 
123
            </div>
 
124
            <div class="section">
 
125
              <div class="head">
 
126
                <h1 id="DESCRIPTION" onclick="switch_section(this)" title="Click title to show/hide section content.">DESCRIPTION</h1>
 
127
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
128
              </div>
 
129
              <div class="body">
 
130
                <p>
 
131
                      The <code>Template::Exception</code> module defines an object class for
 
132
                      representing exceptions within the template processing life cycle.
 
133
                      Exceptions can be raised by modules within the Template Toolkit, or can
 
134
                      be generated and returned by user code bound to template variables.
 
135
                    </p>
 
136
                    <p>
 
137
                      Exceptions can be raised in a template using the <code>THROW</code>
 
138
                      directive,
 
139
                    </p>
 
140
                    <pre>[% THROW user.login 'no user id: please login' %]</pre>
 
141
                    <p>
 
142
                      or by calling the <a href="../../modules/Template/Context.html#method_throw">throw()</a> method on the current <a href="../../modules/Template/Context.html">Template::Context</a> object,
 
143
                    </p>
 
144
                    <pre>$context-&gt;throw('user.passwd', 'Incorrect Password');
 
145
$context-&gt;throw('Incorrect Password');    # type 'undef'</pre>
 
146
                    <p>
 
147
                      or from Perl code by calling <code>die()</code> with a
 
148
                      <code>Template::Exception</code> object,
 
149
                    </p>
 
150
                    <pre>die (Template::Exception-&gt;new('user.denied', 'Invalid User ID'));</pre>
 
151
                    <p>
 
152
                      or by simply calling <code>die()</code> with an error string. This is
 
153
                      automagically caught and converted to an exception of
 
154
                      '<code>undef</code>' type (that's the literal string '<code>undef</code>'
 
155
                      rather than Perl's undefined value) which can then be handled in the
 
156
                      usual way.
 
157
                    </p>
 
158
                    <pre>die "I'm sorry Dave, I can't do that";</pre>
 
159
                    <p>
 
160
                      Each exception is defined by its type and a information component (e.g.
 
161
                      error message). The type can be any identifying string and may contain
 
162
                      dotted components (e.g. '<code>foo</code>', '<code>foo.bar</code>',
 
163
                      '<code>foo.bar.baz</code>'). Exception types are considered to be
 
164
                      hierarchical such that '<code>foo.bar</code>' would be a specific type of
 
165
                      the more general '<code>foo</code>' type.
 
166
                    </p>
 
167
              </div>
 
168
            </div>
 
169
            <div class="section">
 
170
              <div class="head">
 
171
                <h1 id="METHODS" onclick="switch_section(this)" title="Click title to show/hide section content.">METHODS</h1>
 
172
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
173
              </div>
 
174
              <div class="body">
 
175
                <div class="subsection">
 
176
                  <div class="head">
 
177
                    <h2 id="method_type" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">type()</h2>
 
178
                    <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
179
                  </div>
 
180
                  <div class="body">
 
181
                    <p>
 
182
                          Returns the exception type.
 
183
                        </p>
 
184
                  </div>
 
185
                </div>    <div class="subsection">
 
186
                  <div class="head">
 
187
                    <h2 id="method_info" class="method" onclick="switch_subsection(this)" title="Click title to show/hide sub-section content.">info()</h2>
 
188
                    <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
189
                  </div>
 
190
                  <div class="body">
 
191
                    <p>
 
192
                          Returns the exception information.
 
193
                        </p>
 
194
                  </div>
 
195
                </div>
 
196
              </div>
 
197
            </div>
 
198
            <div class="section">
 
199
              <div class="head">
 
200
                <h1 id="AUTHOR" onclick="switch_section(this)" title="Click title to show/hide section content.">AUTHOR</h1>
 
201
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
202
              </div>
 
203
              <div class="body">
 
204
                <p>
 
205
                      Andy Wardley &lt;abw@wardley.org&gt; <a
 
206
                      href="http://wardley.org/">http://wardley.org/</a>
 
207
                    </p>
 
208
              </div>
 
209
            </div>
 
210
            <div class="section">
 
211
              <div class="head">
 
212
                <h1 id="COPYRIGHT" onclick="switch_section(this)" title="Click title to show/hide section content.">COPYRIGHT</h1>
 
213
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
214
              </div>
 
215
              <div class="body">
 
216
                <p>
 
217
                      Copyright (C) 1996-2007 Andy Wardley. All Rights Reserved.
 
218
                    </p>
 
219
                    <p>
 
220
                      This module is free software; you can redistribute it and/or modify it
 
221
                      under the same terms as Perl itself.
 
222
                    </p>
 
223
              </div>
 
224
            </div>
 
225
            <div class="section">
 
226
              <div class="head">
 
227
                <h1 id="SEE_ALSO" onclick="switch_section(this)" title="Click title to show/hide section content.">SEE ALSO</h1>
 
228
                <a href="#body" class="top" title="Back up to the top of the page" >Top</a>
 
229
              </div>
 
230
              <div class="body">
 
231
                <p>
 
232
                      <a href="../../modules/Template.html">Template</a>, <a href="../../modules/Template/Context.html">Template::Context</a>
 
233
                    </p>
 
234
              </div>
 
235
            </div>
 
236
            
 
237
            </div></div>
 
238
          <br class="clear" />
 
239
          <div class="pageinfo">
 
240
            /modules/Template/Exception.html last modified 10:57:47 31-May-2007
 
241
          </div>
 
242
        </div>
 
243
        
 
244
        <div id="footer">
 
245
          <a href="http://opensource.org/" class="osi"></a>
 
246
          <div class="controls">
 
247
          <div class="pager">
 
248
            <a href="../../modules/Template/Document.html" title="Template::Document" class="go back">Back<span class="about"><h4>Template::Document</h4></span></a>
 
249
            <a href="../../modules/Template/index.html" title="Template::* Modules" class="go up">Up<span class="about"><h4>Template::* Modules</h4></span></a>
 
250
            <a href="../../modules/Template/Filters.html" title="Template::Filters" class="go next">Next<span class="about"><h4>Template::Filters</h4></span></a>
 
251
          </div>
 
252
          </div>
 
253
          <div class="copyright">
 
254
            Copyright &copy; 1996-2007 <a href="http://wardley.org/">Andy Wardley</a>.  All Rights Reserved.
 
255
          </div>
 
256
          <div class="licence">
 
257
            The <a href="http://template-toolkit.org/">Template Toolkit</a> is <a href="http://opensource.org/">Open Source</a> software.
 
258
            You can redistribute and/or modify it under the terms of the <a href="http://www.opensource.org/licenses/gpl-license.php">GNU Public Licence</a>
 
259
            or the <a href="http://www.opensource.org/licenses/artistic-license.php">Perl Artistic Licence</a>.
 
260
          </div>
 
261
        </div>
 
262
        <div id="palette">
 
263
          <ul>
 
264
            <li class="first"><a href="#" class="blue" onclick="set_style('Clear Blue')"></a></li>
 
265
            <li><a href="#" class="orange" onclick="set_style('Clear Orange')"></a></li>
 
266
            <li><a href="#" class="green" onclick="set_style('Clear Green')"></a></li>
 
267
            <li><a href="#" class="purple" onclick="set_style('Clear Purple')"></a></li>
 
268
            <li><a href="#" class="grey" onclick="set_style('Clear Grey')"></a></li>
 
269
          </ul>
 
270
        </div>
 
271
    </div>  </body>
 
272
</html>