Skip to content

Commit

Permalink
Merge pull request #173 from AthennaIO/develop
Browse files Browse the repository at this point in the history
chore(handler): add details field to error response
  • Loading branch information
jlenon7 authored Apr 22, 2024
2 parents e46e22c + fb54e60 commit a9f2fa8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/http",
"version": "4.30.0",
"version": "4.31.0",
"description": "The Athenna Http server. Built on top of fastify.",
"license": "MIT",
"author": "João Lenon <[email protected]>",
Expand Down
4 changes: 3 additions & 1 deletion src/handlers/HttpExceptionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
*/

import { Log } from '@athenna/logger'
import { Is, Json, String } from '@athenna/common'
import type { ErrorContext } from '#src/types'
import { Is, Json, String } from '@athenna/common'

export class HttpExceptionHandler {
/**
Expand All @@ -35,6 +35,7 @@ export class HttpExceptionHandler {
code: String.toSnakeCase(error.code || error.name).toUpperCase(),
name: Json.copy(error.name),
message: Json.copy(error.message),
details: Json.copy(error.details),
stack: Json.copy(error.stack)
}

Expand All @@ -51,6 +52,7 @@ export class HttpExceptionHandler {
body.message = 'An internal server exception has occurred.'

delete body.stack
delete body.details
}

response.status(body.statusCode).send(body)
Expand Down

0 comments on commit a9f2fa8

Please sign in to comment.