31 lines
754 B
PHP
31 lines
754 B
PHP
<?php
|
|
|
|
namespace Subcon\Zap\ErrorHandling;
|
|
|
|
use Subcon\Zap\Application;
|
|
|
|
class Handler
|
|
{
|
|
protected $app;
|
|
|
|
public function __construct(Application $app)
|
|
{
|
|
$this->app = $app;
|
|
}
|
|
|
|
public function report(\Throwable $e)
|
|
{
|
|
$resource = fopen('php://stderr', 'w');
|
|
fwrite($resource, "An error was thrown! {$e->getMessage()}");
|
|
fwrite($resource, "{$e->getTraceAsString()}");
|
|
//Log the error.
|
|
}
|
|
|
|
public function reportError(int $error_nr, string $error, ?string $file, ?int $line)
|
|
{
|
|
$resource = fopen('php://stderr', 'w');
|
|
fwrite($resource, "An error occurred! {$error}");
|
|
fwrite($resource, "Occurred in {$file}, at line {$line}.");
|
|
//Log the error.
|
|
}
|
|
} |