2021-01-21 21:06:52 +00:00
|
|
|
'use strict';
|
2012-02-25 16:20:40 +01:00
|
|
|
|
2024-02-05 21:13:02 +01:00
|
|
|
import {ArgsExpressType} from "../../types/ArgsExpressType";
|
|
|
|
import {ErrorCaused} from "../../types/ErrorCaused";
|
2021-01-21 21:06:52 +00:00
|
|
|
|
2024-02-05 21:13:02 +01:00
|
|
|
const stats = require('../../stats')
|
|
|
|
|
|
|
|
exports.expressCreateServer = (hook_name:string, args: ArgsExpressType, cb:Function) => {
|
2012-09-22 15:22:15 +02:00
|
|
|
// Handle errors
|
2024-08-19 16:30:06 +02:00
|
|
|
args.app.set_error_handler((req, res, error)=>{
|
2024-08-19 22:35:49 +02:00
|
|
|
console.log('Error: ', error);
|
2012-09-12 19:34:33 +01:00
|
|
|
// if an error occurs Connect will pass it down
|
|
|
|
// through these "error-handling" middleware
|
|
|
|
// allowing you to respond however you like
|
2024-08-19 16:30:06 +02:00
|
|
|
console.error(error.stack ? error.stack : error.toString());
|
2024-08-19 22:35:49 +02:00
|
|
|
//res.status(500).json({error: 'Sorry, something bad happened!'});
|
2020-11-23 13:24:19 -05:00
|
|
|
stats.meter('http500').mark();
|
2024-08-20 16:09:06 +02:00
|
|
|
res.status(500).json({error: 'Sorry, something bad happened123!'});
|
2024-08-19 16:30:06 +02:00
|
|
|
})
|
|
|
|
|
2020-10-10 22:51:26 -04:00
|
|
|
|
|
|
|
return cb();
|
2020-11-23 13:24:19 -05:00
|
|
|
};
|