Skip to content

Commit

Permalink
Replaced trigger error with handleException (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
emulgeator authored Jun 22, 2023
1 parent 0bb8d50 commit f68169e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/Controller/RestApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,17 @@ public function run($action)
// This is a standard HTTP exception or a redirect exception, simply re-throw it
throw $e;
} catch (\Exception $e) {
trigger_error(
'Unhandled exception of ' . get_class($e) . ' while serving api response. Error: ' . $e->getMessage(),
E_USER_ERROR
);
$errorHandler = Application::getInstance()->getDiContainer()->getErrorHandlerRegistry();

$errorHandler->handleException($e);

$view = new RestTemplate();
$this->response->setStatusCode(500);
$view->setContent(
$this->getErrorResponse(RestException::CODE_INTERNAL_ERROR, RestException::MSG_INTERNAL_ERROR)
);
$view->setContentType($this->response->getContentType());

$this->response->setStatusCode(500);
$this->response->setBody($view);
}
}
Expand Down

0 comments on commit f68169e

Please sign in to comment.