/**
* An include file for setting up the exception handler of the hub
*
- * @author Roland Haeder <webmaster@ship-simu.org>
+ * @author Roland Haeder <webmaster@shipsimu.org>
* @version 0.0
- * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2011 Hub Developer Team
+ * @copyright Copyright (c) 2007 - 2008 Roland Haeder, 2009 - 2012 Hub Developer Team
* @license GNU GPL 3.0 or any newer version
*
* This program is free software: you can redistribute it and/or modify
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// The hub's own exception handler
+// The node's own exception handler
function hub_exception_handler ($exceptionInstance) {
// Is it an object and a valid instance?
if ((is_object($exceptionInstance)) && ($exceptionInstance instanceof FrameworkException)) {
- // Get the regular trace
- $trace = $exceptionInstance->getTrace();
-
- // Get 3 call levels
+ // Init variable
$backTrace = '';
- for ($idx = 0; $idx < 3; $idx++) {
- // Copy array for argument analysis and init variable
- $traceArray = $trace[$idx];
+
+ // Get all call levels from backtrace
+ foreach ($exceptionInstance->getTrace() as $idx => $traceArray) {
+ // Init argument string
$argsString = '';
// Convert arguments type into human-readable
basename($traceArray['file']),
$traceArray['line']
);
- } // END - for
+ } // END - foreach
// Construct the message
$message = sprintf("--------------------------------------------------------------------------------
// Invalid exception instance detected! Do *only* throw exceptions that
// extends our own exception 'FrameworkException' to get such nice
// outputs like above.
- print("exceptionInstance is invalid! Please inform the core developer team.\n");
+ print('exceptionInstance[]=' . gettype($exceptionInstance) . ' is invalid! Please inform the core developer team.');
}
}
// Error handler
function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) {
// Construct the message
- $message = sprintf("File: %s, Line: %s, Code: %s, Message: %s",
+ $message = sprintf('File: %s, Line: %s, Code: %s, Message: %s',
basename($errfile),
$errline,
$errno,
} // END - if
// Create message
- $message = sprintf("File: %s, Line: %s, Code: %s",
+ $message = sprintf('File: %s, Line: %s, Code: %s',
basename($file),
$line,
$code
);
+ // Log assert
+ syslog(LOG_WARNING, $message);
+
// Throw an exception here
throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED);
} // END - function
set_exception_handler('hub_exception_handler');
// Init assert handling
-assert_options(ASSERT_ACTIVE, 1);
-assert_options(ASSERT_WARNING, 0);
-assert_options(ASSERT_BAIL, 0);
-assert_options(ASSERT_QUIET_EVAL, 0);
-assert_options(ASSERT_CALLBACK, '__assertHandler');
+assert_options(ASSERT_ACTIVE , TRUE);
+assert_options(ASSERT_WARNING , FALSE);
+assert_options(ASSERT_BAIL , TRUE);
+assert_options(ASSERT_QUIET_EVAL, FALSE);
+assert_options(ASSERT_CALLBACK , '__assertHandler');
// [EOF]
?>