@metamask/kernel-errors
Version:
35 lines • 1.35 kB
JavaScript
import { assert, literal, object, string } from "@metamask/superstruct";
import { BaseError } from "../BaseError.mjs";
import { marshaledErrorSchema, ErrorCode } from "../constants.mjs";
export class SubclusterNotFoundError extends BaseError {
constructor(subclusterId, options) {
super(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) {
assert(marshaledError, this.struct);
return new SubclusterNotFoundError(marshaledError.data.subclusterId, unmarshalErrorOptions(marshaledError));
}
}
/**
* A superstruct struct for validating marshaled {@link SubclusterNotFoundError} instances.
*/
SubclusterNotFoundError.struct = object({
...marshaledErrorSchema,
code: literal(ErrorCode.SubclusterNotFound),
data: object({
subclusterId: string(),
}),
});
harden(SubclusterNotFoundError);
//# sourceMappingURL=SubclusterNotFoundError.mjs.map