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 |
/** * @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()); } }
/** * @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()); } }
/** * {@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(); } }