Skip to content

Commit

Permalink
chore: Proper logs with error level and exception trace
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliushaertl committed Aug 7, 2024
1 parent c7da9e6 commit 297b42a
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 96 deletions.
8 changes: 4 additions & 4 deletions lib/Controller/AOCSController.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(
* @return DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR, array{message: string}, array{}>
*/
protected function handleError($e): DataResponse {
$this->logger->warning('An internal error or exception occurred: ['. $e->getCode() . ']' . $e->getMessage());
$this->logger->error('An internal error or exception occurred: ' . $e->getMessage(), ['exception' => $e]);
return new DataResponse(['message' => $this->n->t('An unexpected error occurred. More details can be found in the logs. Please reach out to your administration.')], Http::STATUS_INTERNAL_SERVER_ERROR);
}

Expand All @@ -47,7 +47,7 @@ protected function handleError($e): DataResponse {
* @return DataResponse<Http::STATUS_FORBIDDEN, array{message: string}, array{}>
*/
protected function handlePermissionError(PermissionError $e): DataResponse {
$this->logger->warning('A permission error occurred: ['. $e->getCode() . ']' . $e->getMessage());
$this->logger->warning('A permission error occurred: ' . $e->getMessage(), ['exception' => $e]);
return new DataResponse(['message' => $this->n->t('A permission error occurred. More details can be found in the logs. Please reach out to your administration.')], Http::STATUS_FORBIDDEN);
}

Expand All @@ -56,7 +56,7 @@ protected function handlePermissionError(PermissionError $e): DataResponse {
* @return DataResponse<Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*/
protected function handleNotFoundError(NotFoundError $e): DataResponse {
$this->logger->info('A not found error occurred: ['. $e->getCode() . ']' . $e->getMessage());
$this->logger->info('A not found error occurred: ' . $e->getMessage(), ['exception' => $e]);
return new DataResponse(['message' => $this->n->t('A not found error occurred. More details can be found in the logs. Please reach out to your administration.')], Http::STATUS_NOT_FOUND);
}

Expand All @@ -65,7 +65,7 @@ protected function handleNotFoundError(NotFoundError $e): DataResponse {
* @return DataResponse<Http::STATUS_BAD_REQUEST, array{message: string}, array{}>
*/
protected function handleBadRequestError(BadRequestError $e): DataResponse {
$this->logger->warning('An bad request was encountered: ['. $e->getCode() . ']' . $e->getMessage());
$this->logger->warning('An bad request was encountered: ' . $e->getMessage(), ['exception' => $e]);
return new DataResponse(['message' => $this->n->t('An error caused by an invalid request occurred. More details can be found in the logs. Please reach out to your administration.')], Http::STATUS_BAD_REQUEST);
}

Expand Down
Loading

0 comments on commit 297b42a

Please sign in to comment.