https://github.com/msutkowski/hono-boom
A Boom implementation for hono
https://github.com/msutkowski/hono-boom
Last synced: 11 months ago
JSON representation
A Boom implementation for hono
- Host: GitHub
- URL: https://github.com/msutkowski/hono-boom
- Owner: msutkowski
- Created: 2023-02-24T04:10:09.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-24T04:30:42.000Z (over 3 years ago)
- Last Synced: 2025-07-17T19:21:29.669Z (11 months ago)
- Language: TypeScript
- Size: 10.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## hono-boom
### Installation
```
npm install hono-boom
```
### Overview
A simple `Boom` wrapper for hono to provide a `hapi`-er experience!
### Usage
```ts
// Use a guard and resconstruct the error. Useful if you're narrowing against multiple error types like ZodError, FetchError, etc.
if (Boom.isBoom(error)) {
return c.json(
{
error: {
type: error.type,
message: error.message,
details: error.details,
},
},
error.statusCode
);
}
// If we don't have a current user, throw an unauthorized Boom error
if (!currentUser) {
throw Boom.unauthorized();
}
```