lucasfeliciano / restling

Restling is a lightweight Node.js module for building promise-based asynchronous HTTP requests.
MIT License
56 stars 5 forks source link

Progress, timeout, etc. #1

Closed aral closed 10 years ago

aral commented 10 years ago

Hey Lucas,

I couldn’t see the examples for progress and timeout handling, etc. How are these handled in restling vs. restler. Are they supported and/or are you planning on adding support?

Thanks!

lucasfeliciano commented 10 years ago

Hello,

Actually I'm rejecting the promise with a timeout error when the request have a timeout, we can see it here:

.on('timeout', function() {
  reject(new Promise.TimeoutError());
})

I'm open to discuss how to handle that. I can do it better throwing a new Error object instead using the bluebird Promise.TimeoutError which is just a object literal with the name of the error and the message.

What you can do to handle the timeout is in the rejectCallback from the promise verify which error did you get and handle it there.

This answered your question?