|
| 1 | +// Copyright 2023-, Semiotic AI, Inc. |
| 2 | +// SPDX-License-Identifier: Apache-2.0 |
| 3 | + |
| 4 | +//! Module containing Error type and Result typedef |
| 5 | +//! |
| 6 | +
|
| 7 | +use crate::receipt_aggregate_voucher::ReceiptAggregateVoucher; |
| 8 | +use ethers::signers::WalletError; |
| 9 | +use ethers_core::{abi::Address, types::SignatureError}; |
| 10 | +use std::result::Result as StdResult; |
| 11 | +use thiserror::Error as ThisError; |
| 12 | + |
| 13 | +#[derive(ThisError, Debug)] |
| 14 | +pub enum Error { |
| 15 | + #[error("Aggregating receipt results in overflow")] |
| 16 | + AggregateOverflow, |
| 17 | + #[error("Failed to encode to EIP712 hash:\n{source_error_message}")] |
| 18 | + EIP712EncodeError { source_error_message: String }, |
| 19 | + #[error( |
| 20 | + "Unexpected check: {check_string}, only checks provided in initial checklist are valid" |
| 21 | + )] |
| 22 | + InvalidCheckError { check_string: String }, |
| 23 | + #[error("The requested action is invalid for current receipt state: {state}")] |
| 24 | + InvalidStateForRequestedAction { state: String }, |
| 25 | + #[error("Failed to get current system time: {source_error_message} ")] |
| 26 | + InvalidSystemTime { source_error_message: String }, |
| 27 | + #[error(transparent)] |
| 28 | + WalletError(#[from] WalletError), |
| 29 | + #[error(transparent)] |
| 30 | + SignatureError(#[from] SignatureError), |
| 31 | + #[error("Recovered gateway address invalid{address}")] |
| 32 | + InvalidRecoveredSigner { address: Address }, |
| 33 | + #[error("Received RAV does not match expexted RAV")] |
| 34 | + InvalidReceivedRAV { |
| 35 | + received_rav: ReceiptAggregateVoucher, |
| 36 | + expected_rav: ReceiptAggregateVoucher, |
| 37 | + }, |
| 38 | + #[error("Error from adapter: {source_error_message}")] |
| 39 | + AdapterError { source_error_message: String }, |
| 40 | + #[error("Failed to produce rav request, no valid receipts")] |
| 41 | + NoValidReceiptsForRAVRequest, |
| 42 | +} |
| 43 | + |
| 44 | +pub type Result<T> = StdResult<T, Error>; |
0 commit comments