Scalr\Api\Rest\Application::error PHP Method

error() public method

It registers error handler or invokes registered error handler with an exception
public error ( Callable | Exception $e = null )
$e Callable | Exception optional Either the callable handler or exception
    public function error($e = null)
    {
        if (is_callable($e)) {
            $this->error = $e;
        } else {
            $this->response->setStatus(500);
            $this->response->setBody($this->callErrorHandler($e));
            $this->stop();
        }
    }

Usage Example

Example #1
0
 /**
  * @test
  */
 public function testError()
 {
     try {
         $this->app->error();
         $this->assertTrue(false, 'app->error() should throw StopException');
     } catch (StopException $e) {
         $this->assertTrue(true);
         $this->assertEquals(500, $this->app->response->getStatus());
     }
 }
All Usage Examples Of Scalr\Api\Rest\Application::error