@stackbit/sdk
Version:
62 lines • 3.32 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ConfigPresetsError = exports.ConfigValidationError = exports.ModelLoadError = exports.StackbitConfigNotFoundError = exports.ConfigLoadError = exports.STACKBIT_CONFIG_NOT_FOUND = exports.REFER_TO_STACKBIT_CONFIG_DOCS = exports.REFER_TO_STACKBIT_REFERENCE_DOCS = void 0;
exports.REFER_TO_STACKBIT_REFERENCE_DOCS = 'please refer to Stackbit documentation: https://docs.stackbit.com/reference/';
exports.REFER_TO_STACKBIT_CONFIG_DOCS = exports.REFER_TO_STACKBIT_REFERENCE_DOCS + 'config';
exports.STACKBIT_CONFIG_NOT_FOUND = `stackbit.yaml or stackbit.config.js was not found, ${exports.REFER_TO_STACKBIT_CONFIG_DOCS}`;
class ConfigLoadError extends Error {
constructor(message, { originalError } = {}) {
super(message);
this.name = 'ConfigLoadError';
if (originalError) {
this.originalError = originalError;
this.stack = originalError.stack;
}
// redefine "message" as enumerable, this helps comparing the received and the expected error.message in Jest's toMatchObject() tests
Object.defineProperty(this, 'message', { value: message, writable: true, enumerable: true, configurable: true });
}
}
exports.ConfigLoadError = ConfigLoadError;
class StackbitConfigNotFoundError extends Error {
constructor() {
super(exports.STACKBIT_CONFIG_NOT_FOUND);
this.name = 'StackbitConfigNotFoundError';
// redefine "message" as enumerable, this helps comparing the received and the expected error.message in Jest's toMatchObject() tests
Object.defineProperty(this, 'message', { value: exports.STACKBIT_CONFIG_NOT_FOUND, writable: true, enumerable: true, configurable: true });
}
}
exports.StackbitConfigNotFoundError = StackbitConfigNotFoundError;
class ModelLoadError extends Error {
constructor(message, { originalError } = {}) {
super(message);
this.name = 'ModelLoadError';
if (originalError) {
this.originalError = originalError;
this.stack = originalError.stack;
}
// redefine "message" as enumerable, this helps comparing the received and the expected error.message in Jest's toMatchObject() tests
Object.defineProperty(this, 'message', { value: message, writable: true, enumerable: true, configurable: true });
}
}
exports.ModelLoadError = ModelLoadError;
class ConfigValidationError extends Error {
constructor({ message, type, fieldPath, normFieldPath, value }) {
super(message);
this.name = 'ConfigValidationError';
this.type = type;
this.fieldPath = fieldPath;
this.normFieldPath = normFieldPath || fieldPath;
this.value = value;
// redefine "message" as enumerable, this helps comparing the received and the expected error.message in Jest's toMatchObject() tests
Object.defineProperty(this, 'message', { value: message, writable: true, enumerable: true, configurable: true });
}
}
exports.ConfigValidationError = ConfigValidationError;
class ConfigPresetsError extends Error {
constructor(message) {
super(message);
this.name = 'ConfigPresetsError';
}
}
exports.ConfigPresetsError = ConfigPresetsError;
//# sourceMappingURL=config-errors.js.map