UNPKG

@ministryofjustice/hmpps-digital-prison-reporting-frontend

Version:

The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.

27 lines (24 loc) 962 B
import * as Sentry from '@sentry/node'; import logger from './logger.js'; var LoggerErrorType; (function (LoggerErrorType) { LoggerErrorType["INFO"] = "info"; LoggerErrorType["DEBUG"] = "debug"; LoggerErrorType["ERROR"] = "error"; LoggerErrorType["WARN"] = "warn"; })(LoggerErrorType || (LoggerErrorType = {})); const captureDprError = (error, message, meta = {}, type = LoggerErrorType.ERROR) => { const stringMeta = Object.keys(meta).length > 0 ? JSON.stringify(meta) : ''; // Log the error to our logs logger[type]([message, stringMeta].filter(Boolean).join(' '), error); if (type === LoggerErrorType.ERROR) { const extras = message ? { message, ...meta } : meta; // Capture in sentry Sentry.withScope(scope => { scope.setExtras(extras); Sentry.captureException(error); }); } }; export { LoggerErrorType, captureDprError }; //# sourceMappingURL=captureError.js.map