Skip to content

Instantly share code, notes, and snippets.

@giladno
Created November 25, 2017 15:09
Show Gist options
  • Save giladno/c460f76bc6bd79b5a9965895d004e485 to your computer and use it in GitHub Desktop.
Save giladno/c460f76bc6bd79b5a9965895d004e485 to your computer and use it in GitHub Desktop.
ewrap
'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