diff --git a/Core/System/Core/ErrorHandler/ErrorHandler.php b/Core/System/Core/ErrorHandler/ErrorHandler.php new file mode 100644 index 0000000..7f6f3e1 --- /dev/null +++ b/Core/System/Core/ErrorHandler/ErrorHandler.php @@ -0,0 +1,75 @@ +is_notice($errno) || $this->is_warning($errno) || $this->is_fatal_error($errno)){ + $file_without_root_dir = str_replace(str_replace(DIRECTORY_SEPARATOR,'\\',ROOT),'',$errfile); + __show_dev_messages__($errstr, "$errstr " . $file_without_root_dir . " on line $errline"); + } + } + + public function fatalHandler() { + $errfile = "unknown file"; + $errstr = "shutdown"; + $errno = E_CORE_ERROR; + $errline = 0; + + $error = error_get_last(); + + if( $error !== NULL) { + $errfile = $error["file"]; + $errline = $error["line"]; + $errstr = $error["message"]; + $file_without_root_dir = str_replace(str_replace(DIRECTORY_SEPARATOR,'\\',ROOT),'',$errfile); + __show_dev_messages__(substr($errstr,0,50) . '...' , "

$errstr

" . $file_without_root_dir . " on line $errline"); + } + } + + private function is_notice($errno){ + switch ($errno){ + case E_NOTICE: + case E_USER_NOTICE: + case E_DEPRECATED: + case E_USER_DEPRECATED: + case E_STRICT: + return true; + } + } + private function is_warning($errno){ + switch ($errno){ + case E_WARNING: + case E_USER_WARNING: + return true; + } + } + + private function is_fatal_error($errno){ + switch ($errno){ + case E_ERROR: + case E_USER_ERROR: + case E_RECOVERABLE_ERROR: + return true; + } + } + +} + diff --git a/template/base.php b/template/base.php index d92c0fa..b84fbb1 100644 --- a/template/base.php +++ b/template/base.php @@ -5,16 +5,14 @@ - + + <?= $pageTitle ?>