-
-
Notifications
You must be signed in to change notification settings - Fork 174
add specific error messages, error codes, to serialize validation #208
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: master
Are you sure you want to change the base?
add specific error messages, error codes, to serialize validation #208
Conversation
|
No bencmarks for serialize yet, so not posting bench |
|
@MaoShizhong don't mean to step on your contribution #163 here, started writing this before I saw your PR. @wesleytodd I can see how error messages could be considered breaking changes for a package as widely used as cookie, aIthough I don't like it or what people would be depending on. The original change I was doing was just adding in the enriched error messages. It does switch from TypeError to extending The breaking parts can be backed out, and @MaoShizhong could land the error codes independently in a minor. |
I would not consider this a breaking change IF we had provided Maybe you could break them apart and do a |
Given the above discussion, this perhaps may be a naive solution and not something I like particularly much, but would it be viable to add something like declare global {
interface TypeError {
code: string;
}
}to Feels ugly to me but shouldn't be breaking as it'll retain the A caveat would be that it's not particularly obvious to consumers that the thrown error would contain a non-standard TypeError property I wonder if the JSDoc for both of those functions could also include /**
* @throws {TypeError} when invalid option value provided. Error code in .code property.
*/ |
draft take on #163 using a custom error class, and adding in the valid type of arg when its easy to do so.