Skip to content

Commit

Permalink
Documenting error handling when usnig streams
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitor Mattos committed Oct 30, 2014
1 parent f2a44a7 commit dd77511
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ request
.pipe(request.put('http://mysite.com/img.png'))
```

To easily handle errors when streaming requests, listen to the `error` event before piping:

```javascript
request
.get('http://mysite.com/doodle.png')
.on('error', function(err) {
handleError(err)
})
.pipe(fs.createWriteStream('doodle.png'))
```

Now let’s get fancy.

```javascript
Expand Down

0 comments on commit dd77511

Please sign in to comment.