Skip to content

Instantly share code, notes, and snippets.

@booyaa
Created April 19, 2013 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save booyaa/5421788 to your computer and use it in GitHub Desktop.
Save booyaa/5421788 to your computer and use it in GitHub Desktop.
gist created by github.com/dscape/ghcopy
var request = require('request');
request('http://localhost/~booyaa/trigger-404.html', function (err, response, body) {
if (err) {
throw err;
}
if (response.statusCode === 404) {
// throw 'file not found';
throw new Error("file not found");
}
console.log('resp: %s\nbody: %s', JSON.stringify(response, null, 4), JSON.stringify(body, null, 4));
});
process.on('uncaughtException', function (err) {
console.log('uh oh: %s', JSON.stringify(err, null, 4));
process.exit(1);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment