Created
May 26, 2016 15:48
-
-
Save despairblue/ee45362d86a7106997111e1e6806354a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
const express = require('express') | |
const axios = require('axios') | |
const format = require('util').format | |
const app = express() | |
app.use(function (request, response, next) { | |
console.log('Got request') | |
// any of these | |
// throw undefined | |
// next() | |
// next(undefined) | |
// throw null | |
// throw '' | |
// throw false | |
// throw 0 | |
// next(null) | |
// next('') | |
// next(false) | |
// next(0) | |
}) | |
app.use(function (error, request, response, next) { | |
console.log('I want to handle the error but get never called.') | |
console.trace(error) | |
response.json("Don't Panic!") | |
}) | |
app.listen(3001, function () { | |
console.log('Listening ...') | |
axios('http://localhost:3001') | |
.then(function (response) { | |
console.log(`Got response ${format(response)}`) | |
}) | |
.catch(function (error) { | |
console.trace(`Uh Oh: ${format(error)}`) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment