From 36375de86a41b9bf44d5fe5de8da5e13dfe341c0 Mon Sep 17 00:00:00 2001 From: Thibault Martinez Date: Tue, 31 Oct 2023 15:39:51 +0100 Subject: [PATCH] Make errors non_exhaustive (#1542) --- bindings/core/src/error.rs | 1 + cli/src/error.rs | 1 + sdk/src/client/api/block_builder/input_selection/error.rs | 1 + sdk/src/client/error.rs | 1 + sdk/src/client/node_api/error.rs | 1 + sdk/src/client/node_api/mqtt/error.rs | 1 + sdk/src/client/secret/ledger_nano.rs | 1 + sdk/src/client/stronghold/error.rs | 1 + sdk/src/types/api/plugins/participation/error.rs | 1 + sdk/src/types/block/error.rs | 1 + sdk/src/wallet/error.rs | 1 + 11 files changed, 11 insertions(+) diff --git a/bindings/core/src/error.rs b/bindings/core/src/error.rs index 08b54e8adf..d4ed3b0a14 100644 --- a/bindings/core/src/error.rs +++ b/bindings/core/src/error.rs @@ -11,6 +11,7 @@ pub type Result = std::result::Result; /// Error type for the bindings core crate. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// Block errors. #[error("{0}")] diff --git a/cli/src/error.rs b/cli/src/error.rs index 6c6887a293..76e9ef309a 100644 --- a/cli/src/error.rs +++ b/cli/src/error.rs @@ -10,6 +10,7 @@ use rustyline::error::ReadlineError; use serde_json::Error as SerdeJsonError; #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { #[error("block error: {0}")] Block(#[from] BlockError), diff --git a/sdk/src/client/api/block_builder/input_selection/error.rs b/sdk/src/client/api/block_builder/input_selection/error.rs index 14e3303216..9001e8adc0 100644 --- a/sdk/src/client/api/block_builder/input_selection/error.rs +++ b/sdk/src/client/api/block_builder/input_selection/error.rs @@ -12,6 +12,7 @@ use crate::types::block::output::{ChainId, OutputId, TokenId}; /// Errors related to input selection. #[derive(Debug, Eq, PartialEq, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// Block error. #[error("{0}")] diff --git a/sdk/src/client/error.rs b/sdk/src/client/error.rs index e027b7fb04..65ec83edb5 100644 --- a/sdk/src/client/error.rs +++ b/sdk/src/client/error.rs @@ -20,6 +20,7 @@ pub type Result = std::result::Result; /// Error type of the iota client crate. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// Invalid bech32 HRP, should match the one from the used network #[error("invalid bech32 hrp for the connected network: {provided}, expected: {expected}")] diff --git a/sdk/src/client/node_api/error.rs b/sdk/src/client/node_api/error.rs index fa51045934..15dc9267eb 100644 --- a/sdk/src/client/node_api/error.rs +++ b/sdk/src/client/node_api/error.rs @@ -6,6 +6,7 @@ pub type Result = std::result::Result; /// Node errors. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// The requested data was not found. (404) #[error("The requested data {0} was not found.")] diff --git a/sdk/src/client/node_api/mqtt/error.rs b/sdk/src/client/node_api/mqtt/error.rs index c00d75a8cc..5a872ac47b 100644 --- a/sdk/src/client/node_api/mqtt/error.rs +++ b/sdk/src/client/node_api/mqtt/error.rs @@ -3,6 +3,7 @@ /// MQTT related errors. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// Client error. #[error("client error {0}")] diff --git a/sdk/src/client/secret/ledger_nano.rs b/sdk/src/client/secret/ledger_nano.rs index 80fff366f7..e627293adf 100644 --- a/sdk/src/client/secret/ledger_nano.rs +++ b/sdk/src/client/secret/ledger_nano.rs @@ -37,6 +37,7 @@ use crate::{ /// Ledger nano errors. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// Denied by User #[error("denied by user")] diff --git a/sdk/src/client/stronghold/error.rs b/sdk/src/client/stronghold/error.rs index 65db54d5fd..da4abbb44d 100644 --- a/sdk/src/client/stronghold/error.rs +++ b/sdk/src/client/stronghold/error.rs @@ -3,6 +3,7 @@ /// Stronghold errors. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// Crypto.rs error #[error("{0}")] diff --git a/sdk/src/types/api/plugins/participation/error.rs b/sdk/src/types/api/plugins/participation/error.rs index 5171fb97c1..c585d73345 100644 --- a/sdk/src/types/api/plugins/participation/error.rs +++ b/sdk/src/types/api/plugins/participation/error.rs @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #[derive(Debug)] +#[non_exhaustive] pub enum Error { /// Invalid participations error InvalidParticipations, diff --git a/sdk/src/types/block/error.rs b/sdk/src/types/block/error.rs index ef56bb9403..33b23839be 100644 --- a/sdk/src/types/block/error.rs +++ b/sdk/src/types/block/error.rs @@ -28,6 +28,7 @@ use crate::types::block::{ /// Error occurring when creating/parsing/validating blocks. #[derive(Debug, PartialEq, Eq)] #[allow(missing_docs)] +#[non_exhaustive] pub enum Error { ManaAllotmentsNotUniqueSorted, ConsumedAmountOverflow, diff --git a/sdk/src/wallet/error.rs b/sdk/src/wallet/error.rs index 5da143f10a..bffb97443d 100644 --- a/sdk/src/wallet/error.rs +++ b/sdk/src/wallet/error.rs @@ -12,6 +12,7 @@ use crate::types::block::{address::Bech32Address, payload::signed_transaction::T /// The wallet error type. #[derive(Debug, thiserror::Error)] +#[non_exhaustive] pub enum Error { /// Account alias must be unique. #[error("can't create account: account alias {0} already exists")]