Few things, one really important:
*You shared your API token with the world!*
If you can, delete that token and in the future, replace it with a
placeholder when you're posting examples.
Second, *request* you can handle errors in streams, e.g.
* request(options).pipe(fs.createWriteStream(filename)).on('error', err
=> console.log(err));*
However, this is only a part of the solution - the problem is that request
doesn't think that e.g. 404 response will be an error - it'll let you
handle it. Check this answer: http://stackoverflow.com/a/14972828/162070
What it says is to check for the status code before creating your write
stream, something like this:
const r = request(url)
r.on('response', function (resp) {
if (resp.statusCode > 399) { // e.g. 400, 404 or whatever else you
consider failure
throw new Error();
}
r.pipe(new WritableStream())
});
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/ce340ce4-d6e1-40df-a623-0cd8a5ed13f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.