Skip to content

Commit

Permalink
feat: cleanup custom errors
Browse files Browse the repository at this point in the history
Unnecessary things removed.
  • Loading branch information
kirillgroshkov committed Oct 31, 2021
1 parent 13f32d1 commit f5c17b3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 40 deletions.
15 changes: 0 additions & 15 deletions src/validation/ajv/ajvValidationError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,5 @@ export interface AjvValidationErrorData extends ErrorData {
export class AjvValidationError extends AppError<AjvValidationErrorData> {
constructor(message: string, data: AjvValidationErrorData) {
super(message, data)

this.constructor = AjvValidationError
;(this as any).__proto__ = AjvValidationError.prototype
Object.defineProperty(this, 'name', {
value: this.constructor.name,
configurable: true,
})

if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
} else {
Object.defineProperty(this, 'stack', {
value: new Error().stack, // eslint-disable-line unicorn/error-message
})
}
}
}
15 changes: 0 additions & 15 deletions src/validation/joi/joi.validation.error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,5 @@ export interface JoiValidationErrorData extends ErrorData {
export class JoiValidationError extends AppError<JoiValidationErrorData> {
constructor(message: string, data: JoiValidationErrorData) {
super(message, data)

this.constructor = JoiValidationError
;(this as any).__proto__ = JoiValidationError.prototype
Object.defineProperty(this, 'name', {
value: this.constructor.name,
configurable: true,
})

if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor)
} else {
Object.defineProperty(this, 'stack', {
value: new Error().stack, // eslint-disable-line unicorn/error-message
})
}
}
}
1 change: 1 addition & 0 deletions src/validation/joi/joi.validation.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ function createError(value: any, err: ValidationError, objectName?: string): Joi
// Make annotation non-enumerable, to not get it automatically printed,
// but still accessible
Object.defineProperty(data, 'annotation', {
writable: true,
configurable: true,
enumerable: false,
value: annotation,
Expand Down
19 changes: 9 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1425,16 +1425,16 @@
yargs "^17.0.0"

"@naturalcycles/js-lib@^14.0.0":
version "14.55.0"
resolved "https://registry.yarnpkg.com/@naturalcycles/js-lib/-/js-lib-14.55.0.tgz#13359031f233023e924eef1d35ac43c9e0e79e04"
integrity sha512-pHW8dACqat078ZuSD9BfINSuGl8WNsoVYNljnPtUN8KVMgzhmGqt0NmciEy1IkJLl08zse54wNQss9ZX2pwv2Q==
version "14.56.1"
resolved "https://registry.yarnpkg.com/@naturalcycles/js-lib/-/js-lib-14.56.1.tgz#f1c6d244f7a7e8a3a2c0f6f8a91760514e7da943"
integrity sha512-dK3hq4HQaHdkPO8nkVlL40mxclbCaub8tParLF2kp/5zJDJWeEz1lXbyACwLQS9Aj8bNF5TODfduCw/tzyKCmQ==
dependencies:
tslib "^2.0.0"

"@naturalcycles/nodejs-lib@^12.0.0", "@naturalcycles/nodejs-lib@^12.8.0":
version "12.48.2"
resolved "https://registry.yarnpkg.com/@naturalcycles/nodejs-lib/-/nodejs-lib-12.48.2.tgz#e3e8f6e9c770d2e86c7e0b4fb830e25b4630c19e"
integrity sha512-OIBjfAR4dUsrp5729qS1koB39ice+UXPNwsndghpaYn4p8nOHPnlgvl6wIinw6JPnYF1Ht6LEWbXaQa29qF6Iw==
version "12.49.0"
resolved "https://registry.yarnpkg.com/@naturalcycles/nodejs-lib/-/nodejs-lib-12.49.0.tgz#44755fd0a8056713df733aab2f2a2add9b06ff69"
integrity sha512-ge5DJkbZRHCAXNVfGeE76v87XTTdYmggNUupNsySdaOuOJqhTZ/DVEES4ZcVGTaL/CtAq4ywnVOYdp+B4Ob7jA==
dependencies:
"@naturalcycles/js-lib" "^14.0.0"
"@naturalcycles/time-lib" "^3.0.1"
Expand All @@ -1459,7 +1459,6 @@
move-file "^2.0.0"
nanoid "^3.0.0"
sanitize-html "^2.5.2"
supports-color "^8.0.0"
through2-concurrent "^2.0.0"
yargs "^17.0.0"

Expand Down Expand Up @@ -8532,9 +8531,9 @@ node-addon-api@^3.0.0:
integrity sha512-mmcei9JghVNDYydghQmeDX8KoAm0FAiYyIcUt/N4nhyAipB17pllZQDOJD2fotxABnt4Mdz+dKTO7eftLg4d0A==

node-fetch@^2.6.1:
version "2.6.5"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.5.tgz#42735537d7f080a7e5f78b6c549b7146be1742fd"
integrity sha512-mmlIVHJEu5rnIxgEgez6b9GgWXbkZj5YZ7fx+2r94a2E+Uirsp6HsPTPlomfdHtpt/B0cdKviwkoaM6pyvUOpQ==
version "2.6.6"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.6.tgz#1751a7c01834e8e1697758732e9efb6eeadfaf89"
integrity sha512-Z8/6vRlTUChSdIgMa51jxQ4lrw/Jy5SOW10ObaA47/RElsAN2c5Pn8bTgFGWn/ibwzXTE8qwr1Yzx28vsecXEA==
dependencies:
whatwg-url "^5.0.0"

Expand Down

0 comments on commit f5c17b3

Please sign in to comment.