-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
ParseError doesn't inherit from Error #326
Comments
however, I'm not sure how to do this is in ES6, as with this code export default class ParseError extends Error {
constructor(code, message) {
super();
this.code = code;
this.message = message;
}
} |
This is intentional -- A ParseError is not meant to be thrown. It reflects a canonical representation of a difficulty communicating with the server. In early versions of the SDK (before Promises, and certainly before the Promises/A+ spec was written to handle Errors), the object was passed to error callbacks and handled within those. Since then the specs have changed, such that passing an object to the |
Also, a stack trace does not seem helpful. Parse Errors are generated as the response from the server, so they will always trace back to the REST controller, through a confusing, likely-illegible mess of Promise resolutions. Due to the way Promises are resolved through micro-tasks, any exceptions probably won't point back to the code that actually generated them; they create new execution contexts. If you want to get useful error reporting from Parse Errors, you'd need to write some custom code anyways. Regardless of how developers handle errors, I always highly recommend that any Promise chain ends with a |
Closing via #658 |
It has these implications:
We noticed this while using Sentry's raven for error reporting.
References:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error#Custom_Error_Types
The text was updated successfully, but these errors were encountered: