UNPKG

@grouparoo/core

Version:
29 lines (28 loc) 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GrouparooExceptionReporter = void 0; const actionhero_1 = require("actionhero"); const sequelize_1 = require("sequelize"); class GrouparooExceptionReporter extends actionhero_1.Initializer { constructor() { super(); this.loadPriority = 1; this.name = "grouparooExceptionReporter"; } async initialize() { // log the SQL statement which cause the error if we have a Sequelize Error const grouparooExceptionReporter = (error) => { if (error instanceof sequelize_1.DatabaseError || error instanceof sequelize_1.ValidationError || error instanceof sequelize_1.UniqueConstraintError) { // @ts-ignore const sql = error["sql"]; // @ts-ignore const parameters = error["parameters"]; (0, actionhero_1.log)("Problematic SQL statement", "warning", { sql, parameters }); } }; actionhero_1.api.exceptionHandlers.reporters.push(grouparooExceptionReporter); } } exports.GrouparooExceptionReporter = GrouparooExceptionReporter;