@metamask/kernel-errors
Version:
39 lines • 1.52 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VatDeletedError = void 0;
const superstruct_1 = require("@metamask/superstruct");
const BaseError_ts_1 = require("../BaseError.cjs");
const constants_ts_1 = require("../constants.cjs");
class VatDeletedError extends BaseError_ts_1.BaseError {
constructor(vatId, options) {
super(constants_ts_1.ErrorCode.VatDeleted, 'Vat was deleted.', {
...options,
data: { vatId },
});
harden(this);
}
/**
* Unmarshals a {@link MarshaledError} into a {@link VatDeletedError}.
*
* @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 VatDeletedError(marshaledError.data.vatId, unmarshalErrorOptions(marshaledError));
}
}
exports.VatDeletedError = VatDeletedError;
/**
* A superstruct struct for validating marshaled {@link VatDeletedError} instances.
*/
VatDeletedError.struct = (0, superstruct_1.object)({
...constants_ts_1.marshaledErrorSchema,
code: (0, superstruct_1.literal)(constants_ts_1.ErrorCode.VatDeleted),
data: (0, superstruct_1.object)({
vatId: (0, superstruct_1.string)(),
}),
});
harden(VatDeletedError);
//# sourceMappingURL=VatDeletedError.cjs.map