Device stubs and exceptions added

This commit is contained in:
2014-06-06 20:32:40 +02:00
parent 633e254958
commit 64d338cf90
5 changed files with 187 additions and 4 deletions

View File

@ -0,0 +1,30 @@
<?php
namespace NoccyLabs\Gpio\Exception\Handler;
use NoccyLabs\Gpio\Exception\GpioException;
class ConsoleExceptionHandler
{
protected $last;
public function register()
{
$this->last = set_exception_handler( array($this, "onException") );
}
public function onException(Exception $exception)
{
if (is_callable($this->last)) {
call_user_func($this->last, $exception);
}
if ($exception instanceof GpioException) {
$pin = $exception->getPin();
if ($pin) {
$pin->dumpState();
}
}
}
}