[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
|
||||
.onError(({ error, status }) => {
|
||||
if (error instanceof HttpError) {
|
||||
console.error(`[-] HTTP ${error.status}: ${error.message}`)
|
||||
if (error.content instanceof String) return status(error.status, { msg: error.message })
|
||||
const errorMessage = typeof error.content === "string" ? error.content : JSON.stringify(error.content)
|
||||
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 throw error
|
||||
|
||||
Reference in New Issue
Block a user