add specific error messages, error codes, to serialize validation#208
add specific error messages, error codes, to serialize validation#208jonchurch wants to merge 2 commits intojshttp:masterfrom
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.