aheckmann / node-ses

An Amazon SES api for nodejs with proper error handling.
http://aheckmann.github.com/node-ses
MIT License
201 stars 37 forks source link

internal "RequestError" Message should return a string, not an object #34

Open markstos opened 7 years ago

markstos commented 7 years ago

When we catch non-Amazon-Web-Services errors, we try to present them in the format that AWS does for consistency.

AWS returns a human-readable string in the Message field. But here, when we capture a "RequestError", we are currently returning an object:

https://github.com/aheckmann/node-ses/blob/master/lib/email.js#L61

Here's an example of object that was actually returned:

{
  "code": "ECONNRESET",
  "errno": "ECONNRESET",
  "syscall": "read"
}

Unfortunately, no part of that is a human-readable description that we could directly map to our own Message property.

We could use the errno library to get human-readable descriptions of the errors, in cases where the errno key is found.

The current mismatch between strings and objects could cause a failure elsewhere in an application if it's expecting that "Message" will always be a string.

markstos commented 7 years ago

We also generate an internal "ParseError" I have not checked to confirm it returns a string or an object as the "error" value.