Skip to content

Commit 0953bfb

Browse files
authored
Merge pull request #79 from brayden-wong/patch-1
Update error-handling.md
2 parents ecee14c + 63cd933 commit 0953bfb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/patterns/error-handling.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ It's important that `onError` must be call before handler you want to apply
3737

3838
For example, returning custom 404 messages:
3939
```typescript
40-
import { Elysia } from 'elysia'
40+
import { Elysia, NotFoundError } from 'elysia'
4141

4242
new Elysia()
4343
.onError(({ code, error, set }) => {
@@ -47,6 +47,9 @@ new Elysia()
4747
return 'Not Found :('
4848
}
4949
})
50+
.post('/', () => {
51+
throw new NotFoundError();
52+
})
5053
.listen(8080)
5154
```
5255

@@ -119,6 +122,9 @@ new Elysia()
119122
return error
120123
}
121124
})
125+
.get('/', () => {
126+
throw new CustomError('Hello Error');
127+
})
122128
```
123129

124130
## Catching all error

0 commit comments

Comments
 (0)