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
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());
     }
 }
Example #2
0
 /**
  * @test
  */
 public function testError()
 {
     $this->app->getContainer()->apilogger->setIsEnabled(false);
     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());
     }
 }
Example #3
0
 /**
  * {@inheritdoc}
  * @see \Scalr\Api\Rest\Application::error()
  */
 public function error($e = null)
 {
     try {
         parent::error($e);
     } catch (StopException $e) {
         $this->getContainer()->apilogger->log('api.error', $this->request, $this->response);
         $this->stop();
     }
 }