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 <webmaster@mxchange.org>
9 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
10 * @license GNU GPL 3.0 or any newer version
11 * @link http://www.mxchange.org
13 * This program is free software: you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation, either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 abstract class FrameworkException extends ReflectionException {
28 * Array for the backtrace
30 private $backTrace = array();
33 * The super constructor for all exceptions
35 * @param $message The non-optional message for the exception
36 * @param $code An optional code for better debugging
39 public function __construct($message, $code = 0) {
41 $this->saveBackTrace();
44 $message = (string) $message;
47 // make sure everything is assigned properly
48 parent::__construct($message, $code);
52 * Save the current backtrace
56 private final function saveBackTrace () {
57 $this->backTrace = debug_backtrace();
63 * @return $backTrace The full backtrace in an array
65 public final function getBackTrace () {
66 return $this->backTrace;
70 * Returns the name of the thrown exception
72 * @return $toString The name of the thrown exception
74 public function __toString() {
75 return get_class($this);
79 * Getter for hex-decimal code
81 * @return $hexCode The exception code in hex-decimal format
83 public final function getHexCode () {
84 // Get the decimal code
85 $code = $this->getCode();
87 // Format it to hex-decimal, 0x as prefix and 3 chars
88 $hexCode = sprintf("0x%03s", dechex($code));