observing / fullcontact

FullContact API bindings for Node.js
MIT License
42 stars 18 forks source link

Better error handling #19

Open AdriVanHoudt opened 8 years ago

AdriVanHoudt commented 8 years ago

I am encountering an issue where Fullcontact returns a 503 (see https://www.fullcontact.com/developer/docs/#response-codes)

Now I need access to the headers of the response to be able to properly deal with this.

I suggest adding the headers to the error.

3rd-Eden commented 8 years ago

Adding additional info to the returned error seems like a good plain. I've been doing that for quite a while now for HTTP responses using: https://github.com/unshiftio/failure

Where I add things like statusCode, body and headers to the error object. It also automatically adds a toJSON method to the errors so you can easily JSON stringify them for logging purposes.

AdriVanHoudt commented 8 years ago

seems good, you want me to do a pr with that?

3rd-Eden commented 8 years ago

@AdriVanHoudt yeah, a PR would be helpful as you know which props you need to debug these error codes.