Created
November 25, 2017 15:09
-
-
Save giladno/c460f76bc6bd79b5a9965895d004e485 to your computer and use it in GitHub Desktop.
ewrap
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 app = express(); | |
const ewrap = f=>(...args)=>f(...args).catch(args[args.length-1]); | |
app.all('/test', ewrap(async (req, res)=>{ | |
await new Promise(function (resolve, reject) { | |
setTimeout(function () { | |
reject(new Error('this is a test err')); | |
}, 3000); | |
}); | |
})); | |
app.listen(8080); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment