3 * A general abstract exception. You should not throw this even when you
4 * remove the "abstract" key-word. Better you make your own exception and
5 * attach a dedicated message to it.
7 * @author Roland Haeder <roland __NOSPAM__ [at] __REMOVE_ME__ mxchange [dot] org>
10 abstract class FrameworkException extends ReflectionException {
12 * Array for the backtrace
14 private $backTrace = array();
17 * The super constructor for all exceptions
19 * @param $message The non-optional message for the exception
20 * @param $code An optional code for better debugging
23 public function __construct($message, $code = 0) {
25 $this->saveBackTrace();
28 $message = (string) $message;
31 // make sure everything is assigned properly
32 parent::__construct($message, $code);
36 * Save the current backtrace
40 private final function saveBackTrace () {
41 $this->backTrace = debug_backtrace();
47 * @return $backTrace The full backtrace in an array
49 public final function getBackTrace () {
50 return $this->backTrace;
54 * Returns the name of the thrown exception
56 * @return $toString The name of the thrown exception
58 public function __toString() {
59 return get_class($this);
63 * Getter for hex-decimal code
65 * @return $hexCode The exception code in hex-decimal format
67 public final function getHexCode () {
68 // Get the decimal code
69 $code = $this->getCode();
71 // Format it to hex-decimal, 0x as prefix and 3 chars
72 $hexCode = sprintf("0x%03s", dechex($code));