@metamask/kernel-errors
Version:
39 lines • 1.65 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.SubclusterNotFoundError = void 0;
const superstruct_1 = require("@metamask/superstruct");
const BaseError_ts_1 = require("../BaseError.cjs");
const constants_ts_1 = require("../constants.cjs");
class SubclusterNotFoundError extends BaseError_ts_1.BaseError {
constructor(subclusterId, options) {
super(constants_ts_1.ErrorCode.SubclusterNotFound, 'Subcluster does not exist.', {
...options,
data: { subclusterId },
});
harden(this);
}
/**
* Unmarshals a {@link MarshaledError} into a {@link SubclusterNotFoundError}.
*
* @param marshaledError - The marshaled error to unmarshal.
* @param unmarshalErrorOptions - The function to unmarshal the error options.
* @returns The unmarshaled error.
*/
static unmarshal(marshaledError, unmarshalErrorOptions) {
(0, superstruct_1.assert)(marshaledError, this.struct);
return new SubclusterNotFoundError(marshaledError.data.subclusterId, unmarshalErrorOptions(marshaledError));
}
}
exports.SubclusterNotFoundError = SubclusterNotFoundError;
/**
* A superstruct struct for validating marshaled {@link SubclusterNotFoundError} instances.
*/
SubclusterNotFoundError.struct = (0, superstruct_1.object)({
...constants_ts_1.marshaledErrorSchema,
code: (0, superstruct_1.literal)(constants_ts_1.ErrorCode.SubclusterNotFound),
data: (0, superstruct_1.object)({
subclusterId: (0, superstruct_1.string)(),
}),
});
harden(SubclusterNotFoundError);
//# sourceMappingURL=SubclusterNotFoundError.cjs.map