By default, Epsagon automatically captures any unhandled exceptions in your code, and identify other unique scenarios of errors (for example when your service returns a >=500
status code.
In some cases, you need to track down errors (or warnings) that should not interfere with your service.
Issues and alerts
When using a custom error, it will generate an issue, that you can track over time, and it will send you an alert if you've configured to receive alerts for exceptions.
Creating a Custom Error
Let's use the following example, in Node.js:
const epsagon = require('epsagon');
epsagon.init({
token: <EPSAGON-TOKEN: string>,
appName: <APP-NAME-STAGE: string>,
metadataOnly: false,
});
async function test (params) {
// a bad response comes from the DB
epsagon.setError(Error('Unexpected result from DB'));
}
epsagon.nodeWrapper(test)()
This will result in the following trace:


And the following issue:


Another example can be on a try/catch scenario:
const epsagon = require('epsagon');
epsagon.init({
token: 'token',
appName: 'custom-error-demo',
metadataOnly: false,
});
async function test(params) {
try {
// Code crash
} catch (err) {
// Handling the exception, and reporting to Epsagon
epsagon.setError(err);
}
}
epsagon.nodeWrapper(test)()
Updated 5 months ago