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