a1962f38cd
refs https://github.com/TryGhost/Team/issues/597
- To be able to transpile the library for different runtimes (make it polymorphic) had to get rid of dependencies that were not compatible with ES Modules
- By making errors an injectable constructor option it removes the depencency and allows to transpile the library for multiple targets
- The `errors` option is now a required parameter for `loadLimits` method. It errors if it's missing (error message copy inspired by content api error 69fcea0582/packages/content-api/lib/index.js (L21)
)
26 lines
680 B
JavaScript
26 lines
680 B
JavaScript
class Error {
|
|
constructor({errorType, errorDetails, message}) {
|
|
this.errorType = errorType;
|
|
this.errorDetails = errorDetails;
|
|
this.message = message;
|
|
}
|
|
}
|
|
|
|
class IncorrectUsageError extends Error {
|
|
constructor(options) {
|
|
super(Object.assign({errorType: 'IncorrectUsageError'}, options));
|
|
}
|
|
}
|
|
|
|
class HostLimitError extends Error {
|
|
constructor(options) {
|
|
super(Object.assign({errorType: 'HostLimitError'}, options));
|
|
}
|
|
}
|
|
|
|
// NOTE: this module is here to serve as a dummy fixture for Ghost-Ignition's errors (https://github.com/TryGhost/Ignition#errors)
|
|
module.exports = {
|
|
IncorrectUsageError,
|
|
HostLimitError
|
|
};
|