fix image text
[pear] / HTML / FlexyFramework / Error.php
1 <?php
2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
4 // | PHP Version 4                                                        |
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2002 The PHP Group                                |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.02 of the PHP license,      |
9 // | that is bundled with this package in the file LICENSE, and is        |
10 // | available at through the world-wide-web at                           |
11 // | http://www.php.net/license/2_02.txt.                                 |
12 // | If you did not receive a copy of the PHP license and are unable to   |
13 // | obtain it through the world-wide-web, please send a note to          |
14 // | license@php.net so we can mail you a copy immediately.               |
15 // +----------------------------------------------------------------------+
16 // | Authors:  Alan Knowles <alan@akbkhome.com>                           |
17 // +----------------------------------------------------------------------+
18 //
19 // $Id: Error.php,v 1.3 2003/02/22 01:52:50 alan Exp $
20 //
21 // The simple error handler. 
22 //
23
24
25 require_once 'HTML/FlexyFramework/Page.php';
26
27
28 /**
29 * Simple Error handler
30 *
31 *
32 * Currenly just displays a page error.html when you redirect to it.
33 * eg. in your start or get methods do 
34 *
35 * PEAR::RaiseError('some error message');
36 * return 'Error';
37
38 *
39 * Needs to log errors really..
40 *
41 *
42 */
43
44 class HTML_FlexyFramework_Error extends HTML_FlexyFramework_Page {
45         
46     /**
47     * The error page (this should really be configurable using the config file)
48     *
49     * done by overriding the template body..
50     * @var string
51     * @access public
52     */
53     var $template = "error.html";
54
55     /**
56     * Override getAuth to let everyone see the error page.
57     * @access public
58     */
59   
60     function getAuth() 
61     {
62         return;
63     }
64      /**
65     * Override start method to set the $this->error_message to the last recorded error
66     * @access public
67     */
68   
69     function start($request,$isRedirect=false,$args=array()) 
70     {
71         //echo "Running error page";
72         $error = &PEAR::getStaticProperty('pages_error','error');
73        
74         $this->errorMessage = "unknown error";
75         if ($error) {
76             $this->errorMessage = $error->getMessage();
77         }
78         
79     }
80     /**
81     * Store the last Recorded Error message in PEAR::getStaticProperty('pages_error','error');
82     * This is the default hanlder for all pear errors (As set up in the framework class)
83     *
84     * @param pearError
85     * @access public
86     */
87     function raiseError($newError) {
88         
89         $error = &PEAR::getStaticProperty('pages_error','error');
90         $error = $newError;
91     }
92     /**
93     * Fetch the last error object
94     * @return object PEAR error object
95     * @access public
96     */
97     function getError() {
98         return PEAR::getStaticProperty('pages_error','error');
99     }
100     
101 }
102