Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
bin
vendor
composer.lock
.idea/
10 changes: 5 additions & 5 deletions src/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@ public function onError($code, $message, $file, $line) {
switch ($code) {
case E_NOTICE:
case E_USER_NOTICE:
$exc = new Errors\Notice($message, $file, $line, debug_backtrace());
$exc = new Errors\Notice($message, $file, $line, debug_backtrace(), $code);
break;
case E_WARNING:
case E_USER_WARNING:
$exc = new Errors\Warning($message, $file, $line, debug_backtrace());
$exc = new Errors\Warning($message, $file, $line, debug_backtrace(), $code);
break;
case E_ERROR:
case E_CORE_ERROR:
case E_RECOVERABLE_ERROR:
$exc = new Errors\Fatal($message, $file, $line, debug_backtrace());
$exc = new Errors\Fatal($message, $file, $line, debug_backtrace(), $code);
break;
case E_USER_ERROR:
default:
$exc = new Errors\Error($message, $file, $line, debug_backtrace());
$exc = new Errors\Error($message, $file, $line, debug_backtrace(), $code);
}
$this->notifier->notify($exc);
}
Expand All @@ -67,7 +67,7 @@ public function onShutdown()
if ($error['type'] & error_reporting() === 0) {
return;
}
$exc = new Errors\Fatal($error['message'], $error['file'], $error['line']);
$exc = new Errors\Fatal($error['message'], $error['file'], $error['line'], $trace = array(), $error['type']);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, man.

Could you also update onError() such that each of the Base objects that it creates is given the $code as the 5th argument to the constructor?

Copy link
Author

@gfaza gfaza Apr 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'tis done

$this->notifier->notify($exc);
}

Expand Down
9 changes: 8 additions & 1 deletion src/Errors/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ class Base
private $file;
private $line;
private $trace;
private $code;

public function __construct($message, $file, $line, $trace = array())
public function __construct($message, $file, $line, $trace = array(), $code = null)
{
$this->message = $message;
$this->file = $file;
$this->line = $line;
$this->trace = $trace;
$this->code = $code;
}

public function getMessage()
Expand All @@ -38,4 +40,9 @@ public function getTrace()
{
return $this->trace;
}

public function getCode()
{
return $this->code;
}
}
1 change: 1 addition & 0 deletions src/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public function buildNotice($exc)
'type' => get_class($exc),
'message' => $exc->getMessage(),
'backtrace' => $backtrace,
'code' => $exc->getCode(),
);

$context = array(
Expand Down