etherpad-lite/src/node/hooks/express/errorhandling.ts

24 lines
779 B
TypeScript
Raw Normal View History

'use strict';
2012-02-25 16:20:40 +01:00
import {ArgsExpressType} from "../../types/ArgsExpressType";
import {ErrorCaused} from "../../types/ErrorCaused";
const stats = require('../../stats')
exports.expressCreateServer = (hook_name:string, args: ArgsExpressType, cb:Function) => {
// 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);
// 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
})
return cb();
2020-11-23 13:24:19 -05:00
};