Skip to content

Commit

Permalink
Merge pull request #6 from WebFiori/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
usernane committed Jan 8, 2024
2 parents 5c3c5a8 + 0a2151c commit 0158343
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
8 changes: 4 additions & 4 deletions webfiori/error/ErrorHandlerException.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php
namespace webfiori\error;

use Exception;
use ErrorException;
/**
* This class is used to represent PHP errors which was converted to exceptions.
*
* @author Ibrahim
*/
class ErrorHandlerException extends Exception {
class ErrorHandlerException extends ErrorException {
private $debugTrace;
/**
* Creates new instance of the class.
Expand All @@ -18,8 +18,8 @@ class ErrorHandlerException extends Exception {
*
* @param string $file The path to the file at which the error happened.
*/
public function __construct(string $message = "", int $code = 0, string $file = '') {
parent::__construct($message, $code);
public function __construct(string $message = "", int $code = 0, string $file = '', int $line = 0) {
parent::__construct($message, $code, $code, $file, $line);
$this->debugTrace = [];
$trace = debug_backtrace();
$line = null;
Expand Down
9 changes: 4 additions & 5 deletions webfiori/error/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ class Handler {
private $exceptionsHandler;
private $shutdownFunction;
private function __construct() {
//ini_set('display_startup_errors', 1);
//ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);
error_reporting(-1);
$this->errToExceptionHandler = function (int $errno, string $errString, string $errFile, int $errLine) {
//Convert errors to exceptions
$errClass = TraceEntry::extractClassName($errFile);
$errType = Handler::ERR_TYPES[$errno];
$message = 'An exception caused by an error. '.$errType['description'].': '.$errString.' at '.$errClass.' Line '.$errLine;
throw new ErrorHandlerException($message, $errno, $errFile);
throw new ErrorHandlerException($message, $errno, $errFile, $errLine);
};
$this->exceptionsHandler = function (Throwable $ex = null) {
Handler::get()->lastException = $ex;
Expand Down Expand Up @@ -141,9 +141,8 @@ private function __construct() {
}
};
$this->isErrOccured = false;
set_exception_handler($this->exceptionsHandler);
set_error_handler($this->errToExceptionHandler);

set_exception_handler($this->exceptionsHandler);
register_shutdown_function($this->shutdownFunction);
$this->handlersPool = [];
$this->handlersPool[] = new DefaultHandler();
Expand Down

0 comments on commit 0158343

Please sign in to comment.