Exemplo n.º 1
0
 /**
  * Create an exception.
  * An exception is built with a formatted message, a code (an ID), and an
  * array that contains the list of formatted string for the message. If
  * chaining, we can add a previous exception.
  *
  * @param   string      $message      Formatted message.
  * @param   int         $code         Code (the ID).
  * @param   array       $arguments    Arguments to format message.
  * @param   \Throwable  $previous     Previous exception in chaining.
  * @return  void
  */
 public function __construct($message, $code = 0, $arguments = [], $previous = null)
 {
     parent::__construct($message, $code, $arguments, $previous);
     if (false === Event::eventExists('hoa://Event/Exception')) {
         Event::register('hoa://Event/Exception', __CLASS__);
     }
     $this->send();
     return;
 }
Exemplo n.º 2
0
<?php

require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Bootstrap.php';
use Hoa\Exception;
use Hoa\Dispatcher;
use Hoa\Router;
Exception\Error::enableErrorHandler();
Exception\Idle::enableUncaughtHandler();
$dispatcher = new Dispatcher\ClassMethod(['synchronous.call' => 'Application\\Resource\\(:call:U:)', 'synchronous.able' => '(:%variables._method:U:)', 'asynchronous.call' => '(:%synchronous.call:)', 'asynchronous.able' => '(:%synchronous.able:)']);
$router = new Router\Http();
$router->_get('_resource', '/Static/(?<resource>)')->get('dates', '/api/dates(?:/(?<limit>\\d+))?', 'Dates')->get('discography', '/api/discography', 'Discography')->get('album', '/api/album/(?<albumId>.+)', 'Album')->get('videos', '/api/videos', 'Videos')->get('fallback', '/.*', 'Fallback');
$dispatcher->dispatch($router);
Exemplo n.º 3
0
 public function case_enable_uncaught_handler()
 {
     $self = $this;
     $this->given($this->function->set_exception_handler = function ($handler) use($self, &$called) {
         $called = true;
         $self->object($handler)->isInstanceOf('Closure')->let($reflection = new \ReflectionObject($handler))->array($invokeParameters = $reflection->getMethod('__invoke')->getParameters())->hasSize(1)->string($invokeParameters[0]->getName())->isEqualTo('exception');
         return null;
     })->when($result = SUT::enableUncaughtHandler())->then->variable($result)->isNull()->boolean($called)->isTrue();
 }