-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExceptions.php
More file actions
32 lines (24 loc) · 1014 Bytes
/
Exceptions.php
File metadata and controls
32 lines (24 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
abstract class CustomException extends Exception {
protected $message = 'Unknown exception'; // Exception message
private $string; // Unknown
protected $code = 0; // User-defined exception code
protected $file; // Source filename of exception
protected $line; // Source line of exception
private $trace; // Unknown
public function __construct($message = null, $code = 0){
if (!$message) {
throw new $this('Unknown '. get_class($this));
}
parent::__construct($message, $code);
}
public function __toString(){
return get_class($this) . " '{$this->message}' in {$this->file}({$this->line})\n". "{$this->getTraceAsString()}";
}
}
// MySQL Exceptions
class MySQLConnectionException extends CustomException{}
class MySQLInsertException extends CustomException{}
class MySQLDeleteException extends CustomException{}
// Generic Exceptions
?>