-
Notifications
You must be signed in to change notification settings - Fork 225
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
docs(error-handling): add string vs object errors and update createError
jsdoc
#762
Conversation
β¦ client-server context
β¦ation to client side
src/error.ts
Outdated
@@ -62,6 +62,7 @@ export class H3Error<DataT = unknown> extends Error { | |||
* Creates a new `Error` that can be used to handle both internal and runtime errors. | |||
* | |||
* @param input {string | (Partial<H3Error> & { status?: number; statusText?: string })} - The error message or an object containing error properties. | |||
* If a string is provided, it will be used as the error `message`. Remember to use either `statusMessage` or `data` to pass error information to the client. |
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.
This is nice. We might also add markdown docs and examples (similar, maybe smaller version of docs) here as well so when people hover their mouse on utility in their IDE, they see nice inline docs and tip.
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.
Thanks Pooya! I've made some revisions in that direction, what do you think about it now?
Co-authored-by: Pooya Parsa <pyapar@gmail.com>
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.
Thanks β€οΈ
π Linked issue
#761
β Type of change
π Description
I have always been somewhat confused on how to initialize
createError
, either with a string or an object. Similarly, it was unclear at first which one to use to pass data to the client in an error thrown from the server.π Checklist
ποΈ Note
This is my first-ever open source contribution so I may not have configured the issue/pr or the contribution itself as needed. I'd love to hear if that is the case and I'll fix whatever is missing.
And just for context: @pi0 this is the pr I am opening per your suggestion over Twitter. Thanks for the nudge!