Skip to Content
Dec 07, 2020 at 10:42 AM

CAP - Custom error message on oData function/action


Hello experts,

i've a problem returning custom error message on CAP deployed service (developed with BAS).

When I try to run locally on BAS all works fine, but after deploy I get the standard "Internal server error" instead the message I set.

The code I'm using is the following (see doc on req.error

module.exports = (srv) => {

srv.on('getTest', async req => {

try {

var result = await controller._getTest(req)

return result;

} catch (error) {

req.error({code:"500", message: "Custom Error Message"});





In the log of deployed application I can see also the custom error message that seems correctly catched but is not displayed in the response.

Does anyone know how to fix it?Thank you


swgca.png (41.6 kB)
tvq6p.png (52.1 kB)