rendrjs / rendr

Render your Backbone.js apps on the client and the server, using Node.js.
MIT License
4.09k stars 313 forks source link

Include statusText in error object #511

Open ErikLarsson82 opened 8 years ago

ErikLarsson82 commented 8 years ago

When using timeout option for XHR, the error objects needs to differentiate between timeouts and other errors if the applications should be able to handle these differently.

saponifi3d commented 8 years ago

Thanks for the contrib!

I was wondering what you're statusText will be set to when you're using the timeout option? From the docs I was reading it seems like it's simply a bit extra text output from the status code itself, so it seems like you should be able to get all the information from that?

Thanks in advance for furthering my knowledge about XHR statusText too! Would the readyState be helpful for you in this case too? https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState

ErikLarsson82 commented 8 years ago

The error code is 0 when reaching timeout. This is probably incorrect and should probably be solved in a different pull request. I have not been able to figure out why the error code is 0. But i did try to propagate the statusText and our code works using this modification. The statusText simply is 'timeout' in this situation.

saponifi3d commented 8 years ago

Do you think we will need to add any other attributes to this error? There are a lot of additional properties we are not sending in the error from the response.

It also seems like a candidate to make a new Error type so we can catch only these errors in a try / catch block. Thoughts? (I can update that in a separate PR)