diff --git a/docs/essential/life-cycle.md b/docs/essential/life-cycle.md index 9d8b49bd..74c72906 100644 --- a/docs/essential/life-cycle.md +++ b/docs/essential/life-cycle.md @@ -502,7 +502,7 @@ import { validateSession } from './user' new Elysia() .get('/', () => 'hi', { beforeHandle({ set, cookie: { session }, status }) { - if (!validateSession(session.value)) return status(401) + if (!validateSession(session.value)) return status('Unauthorized') } }) .listen(3000) @@ -527,7 +527,7 @@ new Elysia() .guard( { beforeHandle({ set, cookie: { session }, status }) { - if (!validateSession(session.value)) return status(401) + if (!validateSession(session.value)) return status('Unauthorized') } }, (app) => diff --git a/docs/patterns/error-handling.md b/docs/patterns/error-handling.md index 7ad6e6a2..454fc273 100644 --- a/docs/patterns/error-handling.md +++ b/docs/patterns/error-handling.md @@ -308,6 +308,8 @@ new Elysia() }) ``` +Here we use `status(418)` which is the "I'm a teapot" status code. You can also use the string name directly: `status("I'm a teapot")`. See [Status and Headers](/tutorial/getting-started/status-and-headers) for more on using status codes. +