mikeal/request — Issue #87: Error handling with .pipe()?
Author: tmcw
Created: 2011-10-12 17:40:06+00:00
State: open

I'm attempting to refactor some code that currently uses node-get:

```javascript
(new get(url)).toDisk(dl, function(err, file) {
pool.release(obj);
if (err) {
downloads[url].emit('done', err);
delete downloads[url];
return callback(err);
}
fs.rename(dl, filepath, function(err) {
downloads[url].emit('done', err, filepath);
delete downloads[url];
return callback(err, filepath);
});
});
```

Into request, and having some trouble. It seems like there are two ways to use request: simple chaining with `.pipe()` and providing a callback. Earlier I was doing something else: allowing one to stream the file but also catch errors. I don't see an exposed way to both use `.pipe()` and grab errors or success from request. Is there one, that just isn't documented or obvious? Thanks!