Skip to content

Commit a896ae0

Browse files
gobengotylerchilds
authored andcommitted
get rid of custom onError handler
1 parent 4f8c810 commit a896ae0

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

server/src/lib/authz-middleware.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ export function authorizeWithAnyOf(...authzMethods: AuthzMethod[]) {
1515
return next()
1616
}
1717
}
18+
const message = `This request cannot be authorized`
1819
throw new HTTPException(401, {
19-
message: `This request cannot be authorized`,
20+
message,
21+
res: c.json({ message }, 401)
2022
})
2123
}
2224
}
2325

24-
2526
export function authorizeWithSpace(options: {
2627
space: (c: Context) => Promise<ISpace>,
2728
data: Database,

server/src/server.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,6 @@ export class ServerHono extends Hono {
7676
data,
7777
space: (c) => c.req.param('space'),
7878
}))
79-
80-
hono.onError(async (err, c) => {
81-
if (err instanceof HTTPException) {
82-
return c.json({
83-
message: err.message,
84-
status: err.status,
85-
}, err.status)
86-
}
87-
return c.json({
88-
status: 500,
89-
message: `Unexpected error`,
90-
}, 500)
91-
})
9279
}
9380
}
9481

0 commit comments

Comments
 (0)