audit_trails/error.rs
1// Copyright 2020-2026 IOTA Stiftung
2// SPDX-License-Identifier: Apache-2.0
3
4//! Error types returned by the audit-trail public API.
5
6use crate::iota_interaction_adapter::AdapterError;
7
8/// Errors that can occur when reading or mutating an `AuditTrail` object.
9#[derive(Debug, thiserror::Error, strum::IntoStaticStr)]
10#[non_exhaustive]
11pub enum Error {
12 /// Returned when a signer key or public key cannot be derived or validated.
13 #[error("invalid key: {0}")]
14 InvalidKey(String),
15 /// Returned when client configuration or package-ID configuration is invalid.
16 #[error("invalid config: {0}")]
17 InvalidConfig(String),
18 /// Returned when an RPC request fails.
19 #[error("RPC error: {0}")]
20 RpcError(String),
21 /// Error returned by the underlying IOTA client adapter.
22 #[error("IOTA client error: {0}")]
23 IotaClient(#[from] AdapterError),
24 /// Generic catch-all error for crate-specific failures that do not fit a narrower variant.
25 #[error("{0}")]
26 GenericError(String),
27 /// Placeholder for unimplemented API surface.
28 #[error("not implemented: {0}")]
29 NotImplemented(&'static str),
30 /// Returned when a Move tag cannot be parsed.
31 #[error("Failed to parse tag: {0}")]
32 FailedToParseTag(String),
33 /// Returned when an argument is semantically invalid.
34 #[error("Invalid argument: {0}")]
35 InvalidArgument(String),
36 /// The response from the IOTA node API was not in the expected format.
37 #[error("unexpected API response: {0}")]
38 UnexpectedApiResponse(String),
39 /// Failed to deserialize data using BCS.
40 #[error("BCS deserialization error: {0}")]
41 DeserializationError(#[from] bcs::Error),
42 /// The transaction response from the IOTA node API was not in the expected format.
43 #[error("unexpected transaction response: {0}")]
44 TransactionUnexpectedResponse(String),
45}
46
47#[cfg(target_arch = "wasm32")]
48use product_common::impl_wasm_error_from;
49#[cfg(target_arch = "wasm32")]
50impl_wasm_error_from!(Error);