move code up one directory
[atutor.git] / include / classes / Savant2 / Savant2 / Error.php
1 <?php
2
3 /**
4
5 * Provides a simple error class for Savant.
6 *
7 * $Id: Error.php,v 1.2 2005/08/09 22:19:39 pmjones Exp $
8
9 * @author Paul M. Jones <pmjones@ciaweb.net>
10
11 * @package Savant2
12
13 * @license LGPL http://www.gnu.org/copyleft/lesser.html
14
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU Lesser General Public License as
17 * published by the Free Software Foundation; either version 2.1 of the
18 * License, or (at your option) any later version.
19 *
20 * This program is distributed in the hope that it will be useful, but
21 * WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23 * Lesser General Public License for more details.
24
25 */
26
27 class Savant2_Error {
28         
29         
30         /**
31         * 
32         * The error code, typically a SAVANT_ERROR_* constant.
33         * 
34         * @access public
35         *
36         * @var int
37         *
38         */
39         
40         var $code = null;
41         
42         
43         /**
44         * 
45         * An array of error-specific information.
46         * 
47         * @access public
48         *
49         * @var array
50         *
51         */
52         
53         var $info = array();
54         
55         
56         /**
57         * 
58         * The error message text.
59         *
60         * @access public
61         *
62         * @var string
63         *
64         */
65         
66         var $text = null;
67         
68         
69         /**
70         * 
71         * A debug backtrace for the error, if any.
72         *
73         * @access public
74         *
75         * @var array
76         *
77         */
78         
79         var $backtrace = null;
80         
81         
82         /**
83         * 
84         * Constructor.
85         *
86         * @access public
87         *
88         * @param array $conf An associative array where the key is a
89         * Savant2_Error property and the value is the value for that
90         * property.
91         *
92         */
93         
94         function Savant2_Error($conf = array())
95         {
96                 // set public properties
97                 foreach ($conf as $key => $val) {
98                         $this->$key = $val;
99                 }
100                 
101                 // generate a backtrace
102                 if (function_exists('debug_backtrace')) {
103                         $this->backtrace = debug_backtrace();
104                 }
105                 
106                 // extended behaviors
107                 $this->error();
108         }
109         
110         
111         /**
112         * 
113         * Stub method for extended behaviors.
114         *
115         * @access public
116         * 
117         * @return void
118         *
119         */
120         
121         function error()
122         {
123         }
124 }
125 ?>