[F] Fix error logging
This commit is contained in:
+3
-2
@@ -127,8 +127,9 @@ export const app = new Elysia()
|
|||||||
// Error handling: Return status code and message
|
// Error handling: Return status code and message
|
||||||
.onError(({ error, status }) => {
|
.onError(({ error, status }) => {
|
||||||
if (error instanceof HttpError) {
|
if (error instanceof HttpError) {
|
||||||
console.error(`[-] HTTP ${error.status}: ${error.message}`)
|
const errorMessage = typeof error.content === "string" ? error.content : JSON.stringify(error.content)
|
||||||
if (error.content instanceof String) return status(error.status, { msg: error.message })
|
console.error(`[-] HTTP ${error.status}: ${errorMessage}`)
|
||||||
|
if (typeof error.content === "string") return status(error.status, { msg: error.content })
|
||||||
else return status(error.status, error.content)
|
else return status(error.status, error.content)
|
||||||
}
|
}
|
||||||
else throw error
|
else throw error
|
||||||
|
|||||||
Reference in New Issue
Block a user