]> git.mxchange.org Git - hub.git/blobdiff - application/hub/exceptions.php
Introduced package fragmenter class to fragment network packages into smaller chunks
[hub.git] / application / hub / exceptions.php
index 3e621fa94200ef54a237c33305758ab592507d29..62fb49cb9c3fde1e46fdefaa2f325a62afa224ef 100644 (file)
@@ -94,8 +94,48 @@ Backtrace:
        }
 }
 
+// Error handler
+function __errorHandler ($errno, $errstr, $errfile, $errline, array $errcontext) {
+       // Construct the message
+       $message = sprintf("File: %s, Line: %s, Code: %s, Message: %s",
+               basename($errfile),
+               $errline,
+               $errno,
+               $errstr
+       );
+
+       // Throw an exception here
+       throw new FatalErrorException($message, BaseFrameworkSystem::EXCEPTION_FATAL_ERROR);
+} // END - function
+
+// Assertion handler
+function __assertHandler ($file, $line, $code) {
+       // Empty code?
+       if ($code === '') $code = '<em>Unknown</em>';
+
+       // Create message
+       $message = sprintf("File: %s, Line: %s, Code: %s",
+               basename($file),
+               $line,
+               $code
+       );
+
+       // Throw an exception here
+       throw new AssertionException($message, BaseFrameworkSystem::EXCEPTION_ASSERTION_FAILED);
+} // END - function
+
+// Set error handler
+//set_error_handler('__errorHandler');
+
 // Set the new handler
 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');
+
 // [EOF]
 ?>