Skip to content

Commit

Permalink
chore: remove unused error variants
Browse files Browse the repository at this point in the history
  • Loading branch information
RolandSherwin committed Sep 12, 2023
1 parent c4fe4f0 commit 03590a4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 85 deletions.
25 changes: 1 addition & 24 deletions sn_client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
pub(crate) type Result<T> = std::result::Result<T, Error>;

use super::ClientEvent;

use sn_protocol::PrettyPrintRecordKey;
use sn_registers::{Entry, EntryHash};
use std::collections::BTreeSet;
use thiserror::Error;
Expand All @@ -26,7 +24,7 @@ pub enum Error {
#[error("Could not acquire a Semaphore permit.")]
CouldNotAcquireSemaphorePermit(#[from] tokio::sync::AcquireError),

/// Could not acquire a netowrk semaphore
/// Could not acquire a network semaphore
#[error("Network layer does not have the expected concurrency limiter.")]
NoNetworkConcurrencyLimiterFound,

Expand All @@ -48,41 +46,20 @@ pub enum Error {
#[error("Events sender error {0}.")]
EventsSender(#[from] tokio::sync::broadcast::error::SendError<ClientEvent>),

#[error("ResponseTimeout.")]
ResponseTimeout(#[from] tokio::time::error::Elapsed),

/// A general error when verifying a transfer validity in the network.
#[error("Failed to verify transfer validity in the network {0}")]
CouldNotVerifyTransfer(String),

#[error("Chunks error {0}.")]
Chunks(#[from] super::chunks::Error),

#[error("Serialisation error: {0}")]
BincodeError(#[from] bincode::Error),

#[error(
"Content branches detected in the Register which need to be merged/resolved by user. \
Entries hashes of branches are: {0:?}"
)]
ContentBranchDetected(BTreeSet<(EntryHash, Entry)>),

#[error("Missing a payment proof for address {0:?}")]
MissingPaymentProof(String),

/// A general error when a transfer fails.
#[error("Failed to send tokens due to {0}")]
CouldNotSendTokens(String),

/// A general error when a transfer fails.
#[error("Could not verify record was stored on the network {0}")]
CouldNotVerifyRecord(PrettyPrintRecordKey),

/// File system access error.
#[error("System IO Error {0}.")]
SystemIO(#[from] std::io::Error),

/// SelfEncryption error.
#[error("SelfEncryption Error {0}.")]
SelfEncryptionIO(#[from] self_encryption::Error),
}
2 changes: 2 additions & 0 deletions sn_logging/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ pub(super) type Result<T, E = Error> = std::result::Result<T, E>;
pub enum Error {
#[error(transparent)]
Io(#[from] std::io::Error),

#[cfg(feature = "otlp")]
#[error("OpenTelemetry Tracing error: {0}")]
OpenTelemetryTracing(#[from] opentelemetry::trace::TraceError),

#[error("Could not configure logging: {0}")]
LoggingConfigurationError(String),
}
25 changes: 1 addition & 24 deletions sn_networking/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
// KIND, either express or implied. Please review the Licences for the specific language governing
// permissions and limitations relating to use of the SAFE Network Software.

use super::{cmd::SwarmCmd, NetworkEvent};

use libp2p::{
identity::DecodingError,
kad::{self, Record},
request_response::{OutboundFailure, RequestId},
swarm::DialError,
Expand All @@ -18,7 +15,7 @@ use libp2p::{
use sn_protocol::{messages::Response, PrettyPrintRecordKey};
use std::{io, path::PathBuf};
use thiserror::Error;
use tokio::sync::{mpsc, oneshot};
use tokio::sync::oneshot;

pub(super) type Result<T, E = Error> = std::result::Result<T, E>;

Expand All @@ -34,8 +31,6 @@ pub enum Error {
"Not enough store cost quotes returned from the network to ensure a valid fee is paid"
)]
NotEnoughCostQuotes,
#[error("No store cost returned from the network")]
NoStoreCostReturned,

#[error("Close group size must be a non-zero usize")]
InvalidCloseGroupSize,
Expand All @@ -55,9 +50,6 @@ pub enum Error {
#[error("Record retrieved from the network does not match the one we attempted to store {0:}")]
ReturnedRecordDoesNotMatch(PrettyPrintRecordKey),

#[error("Record returned when none was expected (likely a Dbc spend eg) {0:}")]
ExpectedNoRecordToExist(PrettyPrintRecordKey),

#[error("Could not create storage dir: {path:?}, error: {source}")]
FailedToCreateRecordStoreDir {
path: PathBuf,
Expand All @@ -73,27 +65,15 @@ pub enum Error {
#[error("Dial Error")]
DialError(#[from] DialError),

#[error("Libp2p Identity Decode Error")]
Libp2pDecode(#[from] DecodingError),

#[error("This peer is already being dialed: {0}")]
AlreadyDialingPeer(libp2p::PeerId),

#[error("Outbound Error")]
OutboundError(#[from] OutboundFailure),

#[error("Kademlia Store error: {0}")]
KademliaStoreError(#[from] kad::store::Error),

#[error("The mpsc::receiver for `NetworkEvent` has been dropped")]
NetworkEventReceiverDropped(#[from] mpsc::error::SendError<NetworkEvent>),

#[error("A Kademlia event has been dropped: {0:?}")]
ReceivedKademliaEventDropped(kad::KademliaEvent),

#[error("The mpsc::receiver for `SwarmCmd` has been dropped")]
SwarmCmdReceiverDropped(#[from] mpsc::error::SendError<SwarmCmd>),

#[error("The oneshot::sender has been dropped")]
SenderDropped(#[from] oneshot::error::RecvError),

Expand All @@ -106,9 +86,6 @@ pub enum Error {
#[error("Get Record completed with non enough copies")]
RecordNotEnoughCopies(Record),

#[error("Error putting record")]
PutRecordError(#[from] kad::PutRecordError),

#[error("SnProtocol Error")]
ProtocolError(#[from] sn_protocol::error::Error),

Expand Down
5 changes: 1 addition & 4 deletions sn_node/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use sn_networking::Error as NetworkError;
use sn_protocol::error::Error as ProtocolError;
use sn_transfers::{dbc_genesis::Error as GenesisError, wallet::Error as RewardsWalletError};
use sn_transfers::wallet::Error as RewardsWalletError;
use thiserror::Error;

pub(super) type Result<T, E = Error> = std::result::Result<T, E>;
Expand All @@ -23,9 +23,6 @@ pub enum Error {
#[error("Protocol error {0}")]
Protocol(#[from] ProtocolError),

#[error("Genesis error {0}")]
Genesis(#[from] GenesisError),

#[error("Failed to parse NodeEvent")]
NodeEventParsingFailed,

Expand Down
38 changes: 5 additions & 33 deletions sn_protocol/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
// permissions and limitations relating to use of the SAFE Network Software.

use crate::{
storage::{ChunkAddress, DbcAddress, RecordKind, RegisterAddress},
NetworkAddress, PrettyPrintRecordKey,
storage::{DbcAddress, RecordKind, RegisterAddress},
PrettyPrintRecordKey,
};
use serde::{Deserialize, Serialize};
use sn_dbc::{SignedSpend, Token};
use thiserror::Error;
use xor_name::XorName;

/// A specialised `Result` type for protocol crate.
pub type Result<T> = std::result::Result<T, Error>;
Expand All @@ -26,16 +25,10 @@ pub enum Error {
#[error("Record was not stored as no payment supplied: {0:?}")]
InvalidPutWithoutPayment(PrettyPrintRecordKey),

/// At this point in replication flows, payment is ununimportant and should not be supplied
/// At this point in replication flows, payment is unimportant and should not be supplied
#[error("Record should not be a `WithPayment` type: {0:?}")]
UnexpectedRecordWithPayment(PrettyPrintRecordKey),

// ---------- chunk errors
#[error("Chunk not found: {0:?}")]
ChunkNotFound(ChunkAddress),
#[error("Record was not stored: {0:?}: {1:?}")]
RecordNotStored(PrettyPrintRecordKey, String),

// ---------- register errors
#[error("Register was not stored: {0}")]
RegisterNotStored(Box<RegisterAddress>),
Expand Down Expand Up @@ -66,42 +59,21 @@ pub enum Error {
/// Failed to get the storecost from kademlia store
#[error("There was an error getting the storecost from kademlia store")]
GetStoreCostFailed,
#[error("There was an error signing the storecost from kademlia store")]
SignStoreCostFailed,
/// The amount paid by payment proof is not the required for the received content
#[error("The amount paid by payment proof is not the required for the received content, paid {paid}, expected {expected}")]
PaymentProofInsufficientAmount { paid: Token, expected: Token },
/// At least one input of payment proof provided has a mismatching spend Tx
#[error("At least one input of payment proof provided for {0:?} has a mismatching spend Tx")]
PaymentProofTxMismatch(PrettyPrintRecordKey),
/// Payment proof received has no inputs
#[error(
"Payment proof received with record:{0:?}. No payment for our node in its transaction"
)]
NoPaymentToOurNode(PrettyPrintRecordKey),
/// Payment proof provided deemed invalid
#[error("Payment proof provided deemed invalid for item's name {addr_name:?}: {reason}")]
InvalidPaymentProof {
/// XorName the payment proof deemed invalid for
addr_name: XorName,
/// Reason why the payment proof was deemed invalid
reason: String,
},
/// Payments received could not be stored on node's local wallet
#[error("Payments received could not be stored on node's local wallet: {0}")]
FailedToStorePaymentIntoNodeWallet(String),

// ---------- replication errors
/// Replication not found.
#[error("Peer {holder:?} cannot find ReplicatedData {address:?}")]
ReplicatedDataNotFound {
/// Holder that being contacted
holder: Box<NetworkAddress>,
/// Address of the missing data
address: Box<NetworkAddress>,
},

// ---------- record errors
#[error("Record was not stored: {0:?}: {1:?}")]
RecordNotStored(PrettyPrintRecordKey, String),
// Could not Serialize/Deserialize RecordHeader from Record
#[error("Could not Serialize/Deserialize RecordHeader to/from Record")]
RecordHeaderParsingFailed,
Expand Down

0 comments on commit 03590a4

Please sign in to comment.