|
|
@@ -1,6 +1,5 @@
|
|
|
import { Context } from 'hono'
|
|
|
import { z } from '@hono/zod-openapi'
|
|
|
-import { HTTPException } from 'hono/http-exception'
|
|
|
|
|
|
export const ErrorSchema = z.object({
|
|
|
code: z.number().openapi({
|
|
|
@@ -12,18 +11,6 @@ export const ErrorSchema = z.object({
|
|
|
})
|
|
|
|
|
|
export const errorHandler = async (err: Error, c: Context) => {
|
|
|
- if (err instanceof HTTPException) {
|
|
|
- const details = err.cause ? { details: err.cause instanceof Error ? err.cause.message : err.cause } : {}
|
|
|
- return c.json(
|
|
|
- {
|
|
|
- code: err.status,
|
|
|
- message: err.message,
|
|
|
- ...details
|
|
|
- },
|
|
|
- err.status
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
return c.json(
|
|
|
{
|
|
|
code: 500,
|