-
Notifications
You must be signed in to change notification settings - Fork 621
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
chore(encoding/csv): add deprecation to obsolete exports #2633
chore(encoding/csv): add deprecation to obsolete exports #2633
Conversation
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 seem still useful for conditionally handling the errors from encoding/csv
. What is the reasoning for deprecating these?
@kt3k There are four different kinds of export in encoding/csv.ts as of now:
Trivial types exportsI don't think we need to have and export trivial types such as String variable exportsString variable exports are also trivial and easy to reproduce if one needs them. I think they were exported for the test files. Since they are in csv/_util.ts now, there is no need for them to be reexported in the main file. StringifyErrorMost of the std apis do not have "special" errors but use the built in ones, such as ParseError
Therefore the deprecations. |
If a user does other things together with
These are used as part of error message. I think the intention of these being exported is that user can check error like the below: } catch (e) {
if (e instanceof ParseError) {
if (e.message.includes(ERR_BARE_QUOTE)) {
// specific handling for this error
}
}
} |
Yes, that is what I meant. Opened the issue that is in correlation with this #2660.
True. But that is in the specific case of a single try/catch block. One can always nest blocks to handle specific errors without an instance check.
That doesn't make much sense to me. Why not just use a string directly: |
I agree with @timreichen regarding the handling of |
How should we proceed here? Should I bring the pr up to date or revert some of the changes? @kt3k |
I'm currently not in favor of any of these deprecations..
Can you elaborate on why standard errors are better for these cases? @iuioiua |
To be clear, I think If those errors are sufficient for one of the most important encoding APIs in JavaScript, they're sufficient for other encoding APIs. Being consistent with built-in APIs offers familiarity to the developer and is the engineering path of least action. |
I agree with @iuioiua. About the other deprecations: Do you think it is a good idea to export error messages? There are two established patterns for errors in std and deno:
Exporting error messages seems to be like a hybrid and looks more like an anti-pattern to me. |
Hm... I see the intention in exporting error messages. However, I find it odd and inconsistent with other patterns within Deno and its Standard Library. On second thought, if I had to choose, I think deprecating the exporting of error messages is a good idea, but my opinions aren't strong. |
@timreichen As you have observed, error messages are not meant to be enumerated values for automated discrimination checks at runtime for informing program logic — they are intended to impart information to a human observer. Compared to the strong guarantees of things like infallible operations and monadic return types in some other languages — for better or worse — much of JavaScript is simply fallible and exceptions can, and do, occur almost anywhere... which makes exception-handling just as core as any other circumstance in JS for sound and resilient code. The available language features don't make it simple to write concise and elegant exception-handling code without relying on opinionated patterns from libraries, and the pain is exaggerated even further in TypeScript due to things like the lack of formal exception types. Just as is it important for return types to be able to be discriminated by program code to select the appropriate next procedure, it is equally important for exceptions to be able to be discriminated in order to inform recovery steps in exception handling. Error subclasses are one kind of opportunity for discrimination of exceptions for those who want to deduce the exception's origin — and they typically come at very little cost. I recognize that subclasses aren't the only pattern, and this isn't directed specifically at you — I just want to provide more perspective on this issue. |
Why remove a useful feature? Providing the line/column information in the exception allows for an opportunity for the exception to forward potentially helpful information to the provider of the CSV input data: it can be used to inform about the precise position of the parsing error in the source content — which can also be used to slice a contextually-relevant substring from the input for display. Without this information that becomes impossible, and if bad input is provided, the provider has to manually figure out what went wrong — likely write more code to pinpoint the cause of the parse error, etc. |
Closing PR due to staleness. |
@deprecated
tag to obsolete exports inencoding/csv.ts
.