Add BasicHandler & example.php

This commit is contained in:
filp
2013-03-11 23:06:35 +00:00
parent 9e29cd9f9d
commit b61bf22ba1
2 changed files with 46 additions and 0 deletions
+14
View File
@@ -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!");
+32
View File
@@ -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();
}
}