Open
Conversation
georgeevans1995
requested changes
Nov 2, 2022
Contributor
georgeevans1995
left a comment
There was a problem hiding this comment.
Couple of comments, happy to discuss after lunch maybe?
added 8 commits
November 2, 2022 15:54
georgeevans1995
requested changes
Nov 2, 2022
georgeevans1995
approved these changes
Nov 3, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Error v2
Finally managed a refactor of the errors package! 🦞
Aims for v2 were to:
Hence the new version, which:
** Demonstrates clear connection between
ErrorTypes and status codes**The new
ErrorTypeenum maps names (e.g. Forbidden, TooManyRequests) to specific status codes. The enum values have a 1:1 mapping to status codes, reducing naming confusion and increasing transparency. A user can hover over anErrorTypevalue and immediately see the corresponding status code.Includes all HTTP error codes by default
The
ErrorTypeenum has been refactored to include every 4xx and 5xx HTTP status code - except "I'm a teapot" 🫖 .** Provides improved documentation **
The OpenAPI comments have been improved, adding clarity to usage. Every status code in the
ErrorTypeenum has a comment from the MDN docs clarifying its usage. The README has been updated with example usage for v2 and a migration guide.** Allows flexibility for custom context **
Discussed with George, and identified a useful opportunity for projects to define a custom typing for the
contextproperty - so they can have a strictly typed structure if there's e.g. a specific error format they're looking to comply with. README and tests show how this can be used!