Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const express = require('express');
- const app = express();
- const asyncError = (timeout = 500) => new Promise((res, rej) => {
- setTimeout(() => rej(new Error('async error')), timeout);
- });
- app.get('/', async () => {
- await asyncError();
- });
- // should be
- // app.get('/', async (req, res, next) => {
- // try {
- // await asyncError();
- // } catch (err) {
- // next(err);
- // }
- // });
- app.use((err, req, res, next) => {
- res.status(503);
- res.end();
- });
- app.listen(8080);
Add Comment
Please, Sign In to add comment