-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Expose original error object in promises (or callbacks) #4
Comments
Thanks. Clobbering the stack trace is a bug, IMO. |
Fixed in 146b643 and released with 0.9.1-pre.2. |
I think this may have been closed a bit summarily. The code is still littered with usages of this custom Perhaps you want to extend the JS Some examples: aws-sdk-js/lib/xml/parser_xml2js.js Line 56 in 92c766f
aws-sdk-js/lib/xml/parser_xml2js.js Line 134 in 92c766f
aws-sdk-js/lib/xml/parser_xml2js.js Line 166 in 92c766f
aws-sdk-js/lib/query_client.js Line 67 in 4fa2d20
aws-sdk-js/lib/rest_xml_client.js Line 107 in 4fa2d20
aws-sdk-js/lib/services/ec2.js Line 54 in 8d32fd9
Line 181 in 8d32fd9
|
There is a strong pattern across AWS services where the services may respond to a request with an error "code" and "message". The code is always a short string and the message is a longer description, often with details. When I call the EC2 DescribeInstances operation I might get an error back (in XML) that has the following attributes:
The original intent was to limit the number of attributes a user needed to check on errors returned by the SDK. If errors generated by the SDK (or its dependency) mimicked those returned by the services then error handling could be generalized to a point. That said, I see the issue where these object do not generate stack traces and can actually make error handling more difficult. At this point, I think standardizing on An error class (like AWS.Error) that extends Error makes good sense. |
I'm prototyping something based on AWS.Error right now, FYI. |
Add AWS.util.error() to wrap an Error object with extra properties: * code: a unique shorthand code for a service error * statusCode: the HTTP status code of an errant request (if service error) * retryable: whether the request that raised this error should be retried References #4
See the node-errors branch for the code. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
The current error structure in the promises implementation only supports a very simple message, so for situations where an error is thrown from the node.js stack for example, the error is converted into a string and all stack information etc is lost:
aws-sdk-js/lib/http.js
Line 304 in 99f6bfd
It would be nice if the original error object could be added to the error structure so that it can be inspected, etc.
Edit: if node.js-style callbacks are going to be used (fingers crossed), then there shouldn't be any need for this error structure at all - just use/expose JS errors/exceptions.
The text was updated successfully, but these errors were encountered: