diff --git a/ilc/common/CacheWrapper.js b/ilc/common/CacheWrapper.js index d39f439ea..c362ce3ea 100644 --- a/ilc/common/CacheWrapper.js +++ b/ilc/common/CacheWrapper.js @@ -1,7 +1,7 @@ const extendError = require('@namecheap/error-extender'); const errors = {}; -errors.CacheWrapperError = extendError('CacheWrapperError'); +errors.CacheWrapperError = extendError('CacheWrapperError', { defaultData: {} }); class CacheWrapper { #cacheRenewPromise = {}; diff --git a/ilc/common/guard/errors.js b/ilc/common/guard/errors.js index 424461411..bb5f92a14 100644 --- a/ilc/common/guard/errors.js +++ b/ilc/common/guard/errors.js @@ -2,7 +2,7 @@ const extendError = require('@namecheap/error-extender'); const errors = {}; -errors.GuardError = extendError('GuardError'); +errors.GuardError = extendError('GuardError', { defaultData: {} }); errors.GuardTransitionHookError = extendError('GuardTransitionHookError', { parent: errors.GuardError, }); diff --git a/ilc/package-lock.json b/ilc/package-lock.json index 1214f3142..3cf06cfcd 100644 --- a/ilc/package-lock.json +++ b/ilc/package-lock.json @@ -33,6 +33,7 @@ "newrelic": "^11.1.0", "node-html-parser": "^6.1.10", "parseurl": "^1.3.3", + "safe-json-stringify": "^1.2.0", "serve-static": "^1.15.0", "single-spa": "5.6.0", "source-map-support": "^0.5.21", @@ -10303,6 +10304,11 @@ } ] }, + "node_modules/safe-json-stringify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/safe-json-stringify/-/safe-json-stringify-1.2.0.tgz", + "integrity": "sha512-gH8eh2nZudPQO6TytOvbxnuhYBOvDBBLW52tz5q6X58lJcd/tkmqFR+5Z9adS8aJtURSXWThWy/xJtJwixErvg==" + }, "node_modules/safe-regex2": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/safe-regex2/-/safe-regex2-2.0.0.tgz", diff --git a/ilc/package.json b/ilc/package.json index ba8497119..990a919af 100644 --- a/ilc/package.json +++ b/ilc/package.json @@ -45,6 +45,7 @@ "newrelic": "^11.1.0", "node-html-parser": "^6.1.10", "parseurl": "^1.3.3", + "safe-json-stringify": "^1.2.0", "serve-static": "^1.15.0", "single-spa": "5.6.0", "source-map-support": "^0.5.21", diff --git a/ilc/server/errorHandler/ErrorHandler.js b/ilc/server/errorHandler/ErrorHandler.js index 497981a7c..42d855da2 100644 --- a/ilc/server/errorHandler/ErrorHandler.js +++ b/ilc/server/errorHandler/ErrorHandler.js @@ -1,6 +1,7 @@ const fs = require('fs'); const path = require('path'); const { StatusCodes, getReasonPhrase } = require('http-status-codes'); +const safeJsonStringify = require('safe-json-stringify'); const uuidv4 = require('uuid/v4'); const extendError = require('@namecheap/error-extender'); const config = require('config'); @@ -65,7 +66,7 @@ module.exports = class ErrorHandler { const handlingError = new ErrorHandlingError({ message: 'Additional error in error handling', cause: causeErr, - data: { errorId }, + data: { errorId, originalError: safeJsonStringify(err) }, }); this.#logger.error(handlingError); this.#writeStaticError(nres); diff --git a/ilc/server/registry/errors.ts b/ilc/server/registry/errors.ts index bd332055d..d1b572498 100644 --- a/ilc/server/registry/errors.ts +++ b/ilc/server/registry/errors.ts @@ -1,5 +1,5 @@ import extendError from '@namecheap/error-extender'; -export const RegistryError = extendError('RegistryError'); +export const RegistryError = extendError('RegistryError', { defaultData: {} }); export const ValidationRegistryError = extendError('ValidationRegistryError', { parent: RegistryError }); export const NotFoundRegistryError = extendError('NotFoundRegistryError', { parent: RegistryError }); diff --git a/ilc/server/tailor/errors.js b/ilc/server/tailor/errors.js index 17902b8bc..a5d99f6d7 100644 --- a/ilc/server/tailor/errors.js +++ b/ilc/server/tailor/errors.js @@ -1,7 +1,7 @@ const extendError = require('@namecheap/error-extender'); const errors = {}; -errors.TailorError = extendError('TailorError'); +errors.TailorError = extendError('TailorError', { defaultData: {} }); errors.FragmentError = extendError('FragmentError', { parent: errors.TailorError }); errors.FragmentRequestError = extendError('FragmentRequestError', { parent: errors.TailorError }); errors.FragmentWarn = extendError('FragmentWarn', { parent: errors.TailorError }); diff --git a/registry/server/errorHandler/httpErrors.ts b/registry/server/errorHandler/httpErrors.ts index fd85b4c0f..4d3ec78e2 100644 --- a/registry/server/errorHandler/httpErrors.ts +++ b/registry/server/errorHandler/httpErrors.ts @@ -1,6 +1,6 @@ import extendError from '@namecheap/error-extender'; -export const HttpError = extendError('HttpError'); +export const HttpError = extendError('HttpError', { defaultData: {} }); export const NotFoundError = extendError('NotFoundError', { parent: HttpError, }); diff --git a/registry/server/templates/errors.ts b/registry/server/templates/errors.ts index 4dab322ce..5b2d54658 100644 --- a/registry/server/templates/errors.ts +++ b/registry/server/templates/errors.ts @@ -1,6 +1,6 @@ import errorExtender from '@namecheap/error-extender'; export default { - FetchIncludeError: errorExtender('FetchIncludeError'), - InvalidTemplateError: errorExtender('InvalidTemplateError'), + FetchIncludeError: errorExtender('FetchIncludeError', { defaultData: {} }), + InvalidTemplateError: errorExtender('InvalidTemplateError', { defaultData: {} }), }; diff --git a/registry/server/util/helpers.ts b/registry/server/util/helpers.ts index e1b698db6..803550a0d 100644 --- a/registry/server/util/helpers.ts +++ b/registry/server/util/helpers.ts @@ -1,6 +1,5 @@ import Joi, { ValidationError } from 'joi'; import _fp from 'lodash/fp'; -import { type ExtendedError } from '@namecheap/error-extender'; export const joiErrorToResponse = _fp.compose< Array, diff --git a/registry/server/versioning/errors.ts b/registry/server/versioning/errors.ts index 29d60e894..7721e2358 100644 --- a/registry/server/versioning/errors.ts +++ b/registry/server/versioning/errors.ts @@ -1,6 +1,6 @@ import extendError from '@namecheap/error-extender'; -export const VersioningError = extendError('VersioningError'); +export const VersioningError = extendError('VersioningError', { defaultData: {} }); export const NonRevertableError = extendError<{ reason: string }>('NonRevertableError', { parent: VersioningError }); export const NonExistingVersionError = extendError('NonExistingVersionError', { parent: VersioningError,