From d2c734e2aa12929b1d99638850d6cace84d0fb66 Mon Sep 17 00:00:00 2001 From: Gadi Cohen Date: Sat, 30 Jan 2021 10:57:53 +0200 Subject: [PATCH] fix(errors): tsc needs static errors --- src/lib/errors.js | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/lib/errors.js b/src/lib/errors.js index d9eeb05d..dfd0da6f 100644 --- a/src/lib/errors.js +++ b/src/lib/errors.js @@ -1,14 +1,20 @@ -module.exports = {}; - -const errorNames = [ - 'BadRequestError', - 'HTTPError', - 'FailedYahooValidationError', - 'InvalidOptionsError' -]; - -errorNames.forEach(name => { - // Support for the experimental syntax 'classProperties' isn't currently enabled (node 12.0.0) - module.exports[name] = class extends Error {}; - module.exports[name].name = name; -}); +// Support for the experimental syntax 'classProperties' isn't currently enabled (node 12.0.0) + +class BadRequestError extends Error {} +BadRequestError.name = 'BadRequestError'; + +class HTTPError extends Error {} +HTTPError.name = 'HTTPError'; + +class FailedYahooValidationError extends Error {} +FailedYahooValidationError.name = 'FailedYahooValidationError'; + +class InvalidOptionsError extends Error {} +InvalidOptionsError.name = 'InvalidOptionsError'; + +module.exports = { + BadRequestError, + HTTPError, + FailedYahooValidationError, + InvalidOptionsError, +};