mirror of
https://github.com/filp/whoops.git
synced 2026-09-12 02:36:20 +00:00
Add BasicHandler & example.php
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
/**
|
||||
* damnit - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*/
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Using DamnIt with a specific Handler:
|
||||
$run = new DamnIt\Run;
|
||||
$handler = new DamnIt\Handler\BasicHandler;
|
||||
$run->pushHandler($handler);
|
||||
$run->register();
|
||||
|
||||
throw new RuntimeException("Hello!");
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* damnit - php errors for cool kids
|
||||
* @author Filipe Dobreira <http://github.com/filp>
|
||||
*/
|
||||
|
||||
namespace DamnIt\Handler;
|
||||
use DamnIt\Handler\HandlerInterface;
|
||||
|
||||
class BasicHandler extends Handler
|
||||
{
|
||||
/**
|
||||
* @param \Exception
|
||||
* @return int|null
|
||||
*/
|
||||
public function handle(\Exception $exception)
|
||||
{
|
||||
$name = get_class($exception);
|
||||
$message = $exception->getMessage();
|
||||
$file = $exception->getFile();
|
||||
$line = $exception->getLine();
|
||||
|
||||
print "There was an error!\n";
|
||||
print "-> $name\n";
|
||||
print "-> $message\n";
|
||||
print "In file: $file\n";
|
||||
print "In line: $line\n";
|
||||
print "---\n";
|
||||
print "Trace:\n";
|
||||
print $exception->getTraceAsString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user