Skip to content

Commit

Permalink
fix(ilc/server): handle tailor extended errors properly
Browse files Browse the repository at this point in the history
  • Loading branch information
stas-nc committed Apr 3, 2024
1 parent 2666d3c commit 8b5150e
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ilc/common/CacheWrapper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const extendError = require('@namecheap/error-extender');

const errors = {};
errors.CacheWrapperError = extendError('CacheWrapperError');
errors.CacheWrapperError = extendError('CacheWrapperError', { defaultData: {} });

class CacheWrapper {
#cacheRenewPromise = {};
Expand Down
2 changes: 1 addition & 1 deletion ilc/common/guard/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand Down
6 changes: 6 additions & 0 deletions ilc/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ilc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion ilc/server/errorHandler/ErrorHandler.js
Original file line number Diff line number Diff line change
@@ -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');
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion ilc/server/registry/errors.ts
Original file line number Diff line number Diff line change
@@ -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 });
2 changes: 1 addition & 1 deletion ilc/server/tailor/errors.js
Original file line number Diff line number Diff line change
@@ -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 });
Expand Down
2 changes: 1 addition & 1 deletion registry/server/errorHandler/httpErrors.ts
Original file line number Diff line number Diff line change
@@ -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,
});
Expand Down
4 changes: 2 additions & 2 deletions registry/server/templates/errors.ts
Original file line number Diff line number Diff line change
@@ -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: {} }),
};
1 change: 0 additions & 1 deletion registry/server/util/helpers.ts
Original file line number Diff line number Diff line change
@@ -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<Joi.ValidationError>,
Expand Down
2 changes: 1 addition & 1 deletion registry/server/versioning/errors.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 8b5150e

Please sign in to comment.