Added Canvas 1.1.0, originally not under SCM so no historical development records...
[canvas.git] / library / stdexception.php
blobcb06e17da525de7ce143df3ce878b48c44a0a7bf
1 <?php
2 // @title Standard Exception class
3 // @author Matt Todd <matt@matttoddphoto.com>
4 // @created 2005-10-07
5 // @desc A standard Exception class (to be extended)
7 class StdException extends Exception {
8 // private variables
9 public $nErrorCode;
10 public $strErrorMessage;
11 public $strErrorLocation;
12 public $strErrorContext;
13 public $aDump;
15 // constructor
16 public function __construct($nErrorCode = "0099", $strErrorMessage = "Undefined", $strErrorLocation = "", $strErrorContext = "", $aDump = "") {
17 $this->nErrorCode = $nErrorCode;
18 $this->strErrorMessage = $strErrorMessage;
19 $this->strErrorLocation = $strErrorLocation;
20 $this->strErrorContext = $strErrorContext;
21 $this->aDump = $aDump;
24 // functions
25 public function GetErrorCode() {
26 return $this->nErrorCode;
28 public function GetErrorMessage() {
29 return $this->strErrorMessage;
31 public function GetErrorLocation() {
32 return $this->strErrorLocation;
34 public function GetErrorContext() {
35 return $this->strErrorContext;
37 public function GetDump() {
38 return $this->aDump;
40 public function AsString($bHTML = false) {
41 if($bHTML) {
42 return "<strong>Error No. {$this->strErrorCode}</strong>: {$this->strErrorMessage} (<em>{$this->strErrorLocation}</em>)";
43 } else {
44 return "Error No. {$this->strErrorCode}: {$this->strErrorMessage} ({$this->strErrorLocation})";
48 // aliases
49 public function GetError() {
50 return "Error No. " . $this->GetErrorCode() . ": " . $this->GetErrorMessage();