-
Notifications
You must be signed in to change notification settings - Fork 584
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
BREAKING(csv): remove ParseError
#5405
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5405 +/- ##
==========================================
- Coverage 96.35% 96.34% -0.01%
==========================================
Files 458 458
Lines 37751 37729 -22
Branches 5576 5573 -3
==========================================
- Hits 36374 36351 -23
- Misses 1335 1336 +1
Partials 42 42 ☔ View full report in Codecov by Sentry. |
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.
Just found a nit. Otherwise, LGTM! Thanks for this. @kt3k, PTAL.
Also, it does seem like some of these changes could've been done in a separate PR. Not a deal big enough to change now or block this PR, but more for future reference. |
assertEquals(error.startLine, 4); | ||
assertEquals(error.line, 5); | ||
assertEquals(error.column, 0); |
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.
These information will be unavailable. Is that fine?
WDYT? cc @iuioiua
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.
Ah, true. We can store this data within Error.cause
.
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.
We can store this data within Error.cause.
Sounds a reasonable alternative to me. That use case is recommended in the 2nd example https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause#providing_structured_data_as_the_error_cause
But I'm a bit concerned about the unavailability of the type. err.cause
seems always unknown
type. The user need to check type and properties of cause
before accessing it. On the other hand, if it's kept ParseError
, these properties can be accessed after the user checked err instanceof ParseError
, which feels a bit easier and clearer to me. What do you think?
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.
Good point. Actually, now, I'm wondering whether it's worth having those extra details at all. JSON.parse
doesn't do this. E.g. JSON.parse("[1,2,3,")
throws an error with .cause
undefined. We might be fine without. I suggest removing these properties. If it's a sufficiently significant issue in the future, we can revisit. WDYT?
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.
Fair enough. Let's try this and see the community reactions.
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.
LGTM
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.
LGTM once the PR description is complete with what's changed, motivations, and migration guide.
What's changed
ParseError
, which is thrown inparse()
, has been removed and replaced in favor ofSyntaxError
. ThestartLine
,line
andcolumn
properties have been removed also. Error messages have remained unchanged.Motivation
This change was made to align
parse()
with otherparse()
functions in the Standard Library, andJSON.parse()
, which throwSyntaxError
, and without any special properties. This all helps with providing consistent behavior across the Standard Library.Migration guide
To migrate, compare against
SyntaxError
instead ofParseError
when error-handlingparse()
orCsvParseStream
.