-
Notifications
You must be signed in to change notification settings - Fork 421
fix: code typo on error handling tutorial #682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
the code is calling `status()` function from the context, but the handler parameter missed it.
WalkthroughThe Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
docs/tutorial/patterns/error-handling/index.md (1)
43-48: Clarify parameter availability in onError handler documentation.The first example (line 43) destructures
{ code, status }, while a later example (line 72) destructures{ error, code, status }. This inconsistency may confuse readers about which parameters are available or required.Add a brief explanation clarifying that:
- All three parameters (
error,code,status) are available in the onError handler- The first example omits
errorbecause it's not needed for that use case- The second example includes
errorbecause it accesses the error objectThis would help readers understand that parameter destructuring is flexible based on their needs.
Also applies to: 72-79
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
docs/tutorial/patterns/error-handling/index.md(1 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.18.1)
docs/tutorial/patterns/error-handling/index.md
43-43: Hard tabs
Column: 1
(MD010, no-hard-tabs)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (1)
docs/tutorial/patterns/error-handling/index.md (1)
43-43: Hard tabs persist: use spaces for markdown consistency.A previous review flagged hard tabs on this line (MD010 violation), but they appear to remain. Replace the leading hard tab(s) with spaces to align with markdown formatting standards and the file's indentation style.
- .onError(({ code, status }) => { + .onError(({ code, status }) => {
🧹 Nitpick comments (2)
docs/tutorial/patterns/error-handling/index.md (2)
35-37: Documentation should clarify available context properties.The context description lists
errorandcode, but omitsstatus— which is demonstrated in the first code example on line 47 wherestatus(...)is called. The first example also destructures only{ code, status }, noterror, which may confuse readers about what's available and required.Update the context description to include
statusand clarify thaterroris optional (used only when handling specific custom errors):It accept **context** similar to handler but include an additional: -- error - a thrown error +- error - a thrown error (available for custom error handling) - <DocLink href="/essential/life-cycle#error-code">code</DocLink> - error code +- <DocLink href="/essential/handler#status">status</DocLink> - status function to override the error response
43-48: Inconsistent destructuring patterns between examples.The first example (line 43) destructures only
{ code, status }, while the second example (line 72) destructures{ error, code, status }. This inconsistency may suggest thaterroris required in some cases but not others, which needs clarification. Consider adding a brief comment explaining whenerroris needed (e.g., only for custom error handling with type narrowing).Also applies to: 72-79
the code is calling
status()function from the context, but the handler parameter missed it.```typescript import { Elysia } from 'elysia' new Elysia() - .onError(({ error, code }) => { + .onError(({ code, status }) => { // get `status` if(code === "NOT_FOUND") return 'uhe~ are you lost?' return status(418, "My bad! But I\'m cute so you'll forgive me, right?") // where the error happens }) .get('/', () => 'ok') .listen(3000)Summary by CodeRabbit
codeandstatusinstead oferrorandcode, providing direct access to response status for improved error response customization.