Closed car1ot closed 4 years ago
Added in dc-api-core v0.2.4-1.
startup.js:
const { onError } = require('dc-api-core');
onError(info => console.log(info));
controllers/Test.js
module.exports = class Test {
error () { throw new Error('Some unexpected error!'); }
}
Console output:
{
isSystem: false,
controller: 'Test',
action: 'error',
message: 'Some unexpected error!',
error: <Error object>
}
I need to collect
500
errors data. What is the best way to access the error handler globally so as not to make try catch blocks in every request on the controller? P.S. in each request error callback, I need to execute theSentry.captureException(err)
for logging errors by a third-party service.