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@ship-simu.org>
9 * @copyright Copyright(c) 2007, 2008 Roland Haeder, this is free software
10 * @license GNU GPL 3.0 or any newer version
12 * This program is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation, either version 3 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 abstract class FrameworkException extends ReflectionException {
27 * Array for the backtrace
29 private $backTrace = array();
32 * The super constructor for all exceptions
34 * @param $message The non-optional message for the exception
35 * @param $code An optional code for better debugging
38 public function __construct($message, $code = 0) {
40 $this->saveBackTrace();
43 $message = (string) $message;
46 // make sure everything is assigned properly
47 parent::__construct($message, $code);
51 * Save the current backtrace
55 private final function saveBackTrace () {
56 $this->backTrace = debug_backtrace();
62 * @return $backTrace The full backtrace in an array
64 public final function getBackTrace () {
65 return $this->backTrace;
69 * Returns the name of the thrown exception
71 * @return $toString The name of the thrown exception
73 public function __toString() {
74 return get_class($this);
78 * Getter for hex-decimal code
80 * @return $hexCode The exception code in hex-decimal format
82 public final function getHexCode () {
83 // Get the decimal code
84 $code = $this->getCode();
86 // Format it to hex-decimal, 0x as prefix and 3 chars
87 $hexCode = sprintf("0x%03s", dechex($code));