diff --git a/js/actions/system/api-system.js b/js/actions/system/api-system.js index be5c2b868f..7c9149b941 100644 --- a/js/actions/system/api-system.js +++ b/js/actions/system/api-system.js @@ -84,7 +84,17 @@ function Routing (req, res) { req.urlParameters = {}; } - action.route.callback.controller(req, res, action.route.callback.options, next); + var func = action.route.callback.controller; + if (func === null || typeof func !== 'function') { + func = actions.errorFunction(action.route, 'Invalid callback definition found for route ' + JSON.stringify(action.route)); + } + + try { + func(req, res, action.route.callback.options, next); + } + catch (err) { + actions.errorFunction(action.route, 'A runtime error occurred while executing an action: ' + String(err))(req, res, action.route.callback.options, next); + } } next = function () { diff --git a/js/server/modules/org/arangodb/actions.js b/js/server/modules/org/arangodb/actions.js index 70838740a0..1f7e953c11 100644 --- a/js/server/modules/org/arangodb/actions.js +++ b/js/server/modules/org/arangodb/actions.js @@ -1445,6 +1445,7 @@ function redirectRequest (req, res, options, next) { exports.defineHttp = defineHttp; exports.getErrorMessage = getErrorMessage; exports.getJsonBody = getJsonBody; +exports.errorFunction = errorFunction; exports.reloadRouting = reloadRouting; exports.firstRouting = firstRouting; exports.nextRouting = nextRouting;