Skip to content

Commit

Permalink
fix(errors): tsc needs static errors
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Jan 30, 2021
1 parent 33a266b commit d2c734e
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions src/lib/errors.js
Original file line number Diff line number Diff line change
@@ -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,
};

0 comments on commit d2c734e

Please sign in to comment.