dbgate-tools 5.5.4-alpha.2 → 5.5.4-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,6 +19,7 @@ const pick_1 = __importDefault(require("lodash/pick"));
19
19
  const compact_1 = __importDefault(require("lodash/compact"));
20
20
  const getLogger_1 = require("./getLogger");
21
21
  const schemaInfoTools_1 = require("./schemaInfoTools");
22
+ const stringTools_1 = require("./stringTools");
22
23
  const logger = (0, getLogger_1.getLogger)('dbAnalyser');
23
24
  const STRUCTURE_FIELDS = ['tables', 'collections', 'views', 'matviews', 'functions', 'procedures', 'triggers'];
24
25
  const fp_pick = arg => array => (0, pick_1.default)(array, arg);
@@ -319,7 +320,7 @@ class DatabaseAnalyser {
319
320
  return res;
320
321
  }
321
322
  catch (err) {
322
- logger.error({ err, message: err.message, template }, 'Error running analyser query');
323
+ logger.error((0, stringTools_1.extractErrorLogData)(err, { template }), 'Error running analyser query');
323
324
  return {
324
325
  rows: [],
325
326
  };
@@ -17,6 +17,7 @@ const flatten_1 = __importDefault(require("lodash/flatten"));
17
17
  const uniqBy_1 = __importDefault(require("lodash/uniqBy"));
18
18
  const getLogger_1 = require("./getLogger");
19
19
  const structureTools_1 = require("./structureTools");
20
+ const stringTools_1 = require("./stringTools");
20
21
  const logger = (0, getLogger_1.getLogger)('sqlGenerator');
21
22
  class SqlGenerator {
22
23
  constructor(dbinfo, options, objects, dmp, driver, pool) {
@@ -28,7 +29,7 @@ class SqlGenerator {
28
29
  this.isTruncated = false;
29
30
  this.isUnhandledException = false;
30
31
  this.handleException = error => {
31
- logger.error({ error }, 'Unhandled error');
32
+ logger.error((0, stringTools_1.extractErrorLogData)(error), 'Unhandled error');
32
33
  this.isUnhandledException = true;
33
34
  };
34
35
  this.dbinfo = (0, structureTools_1.extendDatabaseInfo)(dbinfo);
@@ -24,3 +24,8 @@ export declare function getConvertValueMenu(value: any, onSetValue: any, editorT
24
24
  text: string;
25
25
  onClick: () => any;
26
26
  }[];
27
+ export declare function extractErrorMessage(err: any, defaultMessage?: string): any;
28
+ export declare function extractErrorLogData(err: any, additionalFields?: {}): {
29
+ errorMessage: any;
30
+ errorObject: any;
31
+ };
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getConvertValueMenu = exports.detectTypeIcon = exports.detectCellDataType = exports.parseSqlDefaultValue = exports.getAsImageSrc = exports.arrayBufferToBase64 = exports.isWktGeometry = exports.getIconForRedisType = exports.isJsonLikeLongString = exports.shouldOpenMultilineDialog = exports.safeJsonParse = exports.stringifyCellValue = exports.parseCellValue = exports.hexStringToArray = exports.arrayToHexString = void 0;
6
+ exports.extractErrorLogData = exports.extractErrorMessage = exports.getConvertValueMenu = exports.detectTypeIcon = exports.detectCellDataType = exports.parseSqlDefaultValue = exports.getAsImageSrc = exports.arrayBufferToBase64 = exports.isWktGeometry = exports.getIconForRedisType = exports.isJsonLikeLongString = exports.shouldOpenMultilineDialog = exports.safeJsonParse = exports.stringifyCellValue = exports.parseCellValue = exports.hexStringToArray = exports.arrayToHexString = void 0;
7
7
  const isString_1 = __importDefault(require("lodash/isString"));
8
8
  const isArray_1 = __importDefault(require("lodash/isArray"));
9
9
  const isNumber_1 = __importDefault(require("lodash/isNumber"));
@@ -442,3 +442,29 @@ function getConvertValueMenu(value, onSetValue, editorTypes) {
442
442
  ];
443
443
  }
444
444
  exports.getConvertValueMenu = getConvertValueMenu;
445
+ function extractErrorMessage(err, defaultMessage = 'Unknown error') {
446
+ if (!err) {
447
+ return defaultMessage;
448
+ }
449
+ if ((0, isArray_1.default)(err.errors)) {
450
+ try {
451
+ return err.errors.map(x => x.message).join('\n');
452
+ }
453
+ catch (e2) { }
454
+ }
455
+ if (err.message) {
456
+ return err.message;
457
+ }
458
+ const s = `${err}`;
459
+ if (s && (!s.endsWith('Error') || s.includes(' '))) {
460
+ return s;
461
+ }
462
+ return defaultMessage;
463
+ }
464
+ exports.extractErrorMessage = extractErrorMessage;
465
+ function extractErrorLogData(err, additionalFields = {}) {
466
+ if (!err)
467
+ return null;
468
+ return Object.assign({ errorMessage: extractErrorMessage(err), errorObject: err }, additionalFields);
469
+ }
470
+ exports.extractErrorLogData = extractErrorLogData;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "5.5.4-alpha.2",
2
+ "version": "5.5.4-alpha.4",
3
3
  "name": "dbgate-tools",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
@@ -25,14 +25,14 @@
25
25
  ],
26
26
  "devDependencies": {
27
27
  "@types/node": "^13.7.0",
28
- "dbgate-types": "^5.5.4-alpha.2",
28
+ "dbgate-types": "^5.5.4-alpha.4",
29
29
  "jest": "^24.9.0",
30
30
  "ts-jest": "^25.2.1",
31
31
  "typescript": "^4.4.3"
32
32
  },
33
33
  "dependencies": {
34
34
  "dbgate-query-splitter": "^4.10.5",
35
- "dbgate-sqltree": "^5.5.4-alpha.2",
35
+ "dbgate-sqltree": "^5.5.4-alpha.4",
36
36
  "debug": "^4.3.4",
37
37
  "json-stable-stringify": "^1.0.1",
38
38
  "lodash": "^4.17.21",