示例#1
0
 /**
  * When you need to send a not found in your runnable, you
  * can call this directly.
  * Optionally, you can specify the package name, class name,
  * and method name to render accordingly.
  * @param sring $package (optional) default 'DefaultPackage'
  * @param sring $class (optional) default 'Error'
  * @param sring $method (optional) default 'notFound'
  * @return void
  */
 public function notFound($package = 'DefaultPackage', $class = 'Error', $method = 'notFound')
 {
     $this->response->setStatus(404);
     $this->view->setPackage($package);
     $this->view->setClass($class);
     $this->view->setScriptName($method);
     return;
 }
示例#2
0
 public function testSetStatus()
 {
     $this->response->setStatus(404);
     $this->assertEquals(404, $this->response->getStatus());
 }
示例#3
0
 /**
  * In the event of an uncaught Exception at point of run, this method will be called
  * by default it'll look for 'DefaultPackage::Error::uncaughtError' before
  * manipulating the response directly and returning to the user.
  * It's environmental sensitive, so will format things accordingly.
  * @param \Exception $throwable
  * @codeCoverageIgnore
  */
 private function error(\Exception $throwable)
 {
     if ($this->env->isProduction()) {
         if (false != ($errorClass = $this->getErrorClass())) {
             try {
                 $this->response->setStatus(500);
                 $instance = $this->getRunnable('DefaultPackage', 'Error', 'uncaughtException', $errorClass);
                 if (is_callable(array($instance, 'uncaughtException'))) {
                     $instance->uncaughtException();
                 } else {
                     $e = new RunnableNotFoundException('Runnable not found');
                     $e->setAdditionalData('Expected: ', '\\DefaultPackage\\src\\Error::uncaughtException()');
                     throw $e;
                 }
                 $instance->finalise();
                 return;
             } catch (\Exception $e) {
                 // Ignore, we're already here.
             }
         }
         @ob_get_clean();
         $this->response->setStatus(500);
         $this->response->setBody('<h1 style="font:28px/1.5 Helvetica,Arial,Verdana,sans-serif;">Application Error</h1>');
         $this->response->sendResponse();
         return;
     } else {
         FormattedException::display($throwable);
         return;
     }
 }