Skip to content

Commit

Permalink
add errors example
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 6, 2023
1 parent 60edaae commit dcac214
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion docs/content/1.guide/7.plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default defineNitroPlugin((nitro) => {
See the [source code](https://github.com/unjs/nitro/blob/main/src/runtime/types.ts#L24) for list of all available runtime hooks.

- `"close", () => {}`
- `"error", (error, context) => {}`
- `"error", (error, { event? }) => {}`
- `"render:response:", (response, { event }) => {}`

## Examples
Expand Down Expand Up @@ -101,3 +101,15 @@ export default defineNitroPlugin((nitro) => {
});
})
```

### Capturing Errors

You can use plugins to capture all application errors.

```ts
export default defineNitroPlugin((nitro) => {
nitro.hooks.hookOnce("error", async (error, { event }) => {
console.error(`${event.path} Application error:`, error)
});
})
```

0 comments on commit dcac214

Please sign in to comment.