@webbio/viper-core-utils
Version:
Webbio's error interface which is used in the Viper Project
32 lines • 1.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const init_1 = tslib_1.__importDefault(require("./init"));
// tslint:disable-next-line: variable-name no-var-requires
class SentryLogger {
/**
* Log the error to the sentry service
* @param error An error that implements the IError schema
*/
log(error) {
// Rewrite the BaseError to a native Error class
// Otherwise Sentry.io does not recognize the error
const nativeError = new Error();
nativeError.name = error.getName();
if (typeof error.getMessage() !== 'undefined') {
nativeError.message = error.getMessage();
}
if (typeof error.getStack() !== 'undefined') {
nativeError.stack = error.getStack();
}
const logger = init_1.default.getLoggingLibrary();
if (logger !== undefined) {
logger.captureException(nativeError);
}
else {
throw new Error('Error Logger has not been initialized with a logger yet.');
}
}
}
exports.default = SentryLogger;
//# sourceMappingURL=sentry.logger.js.map