Skip to content

Commit 5964cab

Browse files
committed
docs(essential): show string status names in lifecycle and error handling
Add inline comments showing string alternatives in: - docs/essential/life-cycle.md (script setup demo) - docs/patterns/error-handling.md (script setup and code examples)
1 parent 088fc32 commit 5964cab

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

docs/essential/life-cycle.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const demo = new Elysia()
2828
})
2929
.get('/throw', ({ status }) => {
3030
// This will be caught by onError
31-
throw status(418)
31+
throw status(418) // or status("I'm a teapot")
3232
})
3333
.get('/return', ({ status }) => {
3434
// This will NOT be caught by onError
35-
return status(418)
35+
return status(418) // or status("I'm a teapot")
3636
})
3737
</script>
3838

docs/patterns/error-handling.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ const demo = new Elysia()
2828
})
2929
.get('/throw', ({ error }) => {
3030
// This will be caught by onError
31-
throw error(418)
31+
throw error(418) // or error("I'm a teapot")
3232
})
3333
.get('/return', ({ status }) => {
3434
// This will NOT be caught by onError
35-
return status(418)
35+
return status(418) // or status("I'm a teapot")
3636
})
3737

3838
const demo2 = new Elysia()
@@ -300,11 +300,11 @@ new Elysia()
300300
})
301301
.get('/throw', ({ status }) => {
302302
// This will be caught by onError
303-
throw status(418)
303+
throw status(418) // or status("I'm a teapot")
304304
})
305305
.get('/return', ({ status }) => {
306306
// This will NOT be caught by onError
307-
return status(418)
307+
return status(418) // or status("I'm a teapot")
308308
})
309309
```
310310

0 commit comments

Comments
 (0)