3 * PHPDoc Error Handling class
\r
5 * PHPDoc "throws" an error class derived from this class whenever
\r
6 * an error occurs. PHPDoc saves the error object to the public array
\r
7 * $this->err[] which exists in every PHPDoc class and tries to return
\r
8 * a useful value that indicates that something might have gone wrong.
\r
10 * The class is widely equal to the PEAR error handling class PEAR_ERROR.
\r
12 * @author Ulf Wendel <ulf.wendel@phpdoc.de>
\r
13 * @version $Id: PhpdocError.php,v 1.2 2000/12/03 22:37:36 uw Exp $
\r
19 * Name of the error object class used to construct the error message
\r
20 * @var string $classname
\r
22 var $classname = "PhpdocError";
\r
25 * Error message prefix.
\r
26 * @var string $error_message_prefix
\r
28 var $error_message_prefix = "";
\r
31 * Error prepend, used for HTML formatting.
\r
32 * @var string $error_prepend
\r
34 var $error_prepend = "<b>";
\r
37 * Error append, used for HTML formatting.
\r
38 * @var string $error_append
\r
40 var $error_append = "</b>";
\r
43 * The error message itself.
\r
45 * Use getMessage() to access it.
\r
47 * @var string $message
\r
48 * @see PhpdocError()
\r
53 * File where the error occured.
\r
55 * @see PhpdocError()
\r
60 * Line number where the error occured.
\r
61 * @var integer $line
\r
62 * @see PhpdocError()
\r
67 * Array that describes how an error gets handled.
\r
68 * @var array $errorHandling
\r
69 * @see PhpdocError()
\r
71 var $errorHandling = array(
\r
78 * Sets the error message, filename and linenumber.
\r
80 * @param string Errormessage
\r
81 * @param string Name of the file where the error occured, use __FILE__ for this
\r
82 * @param string Linenumber where the error occured, use __LINE__ for this
\r
84 function PhpdocError($message, $file, $line) {
\r
86 $this->message = $message;
\r
87 $this->file = $file;
\r
88 $this->line = $line;
\r
90 if ($this->errorHandling["print"])
\r
91 $this->printMessage();
\r
93 if ($this->errorHandling["trigger"])
\r
94 trigger_error($this->getMessage(), "E_USER_NOTICE");
\r
96 if ($this->errorHandling["die"])
\r
97 die($this->getMessage);
\r
99 } // end func PhpdocError
\r
102 * Returns a string with the error message.
\r
105 function getMessage() {
\r
107 return sprintf("%s%s: %s [File: %s, Line: %s]%s",
\r
108 $this->error_prepend,
\r
109 $this->error_message_prefix,
\r
113 $this->error_append);
\r
115 } // end func getMessage
\r
118 * Prints the error message.
\r
119 * @brother getMessage()
\r
121 function printMessage() {
\r
122 print $this->getMessage();
\r
123 } // end func printMessage
\r
125 } // end class PhpdocError
\r