Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Mar 10, 2024
1 parent dfe19fa commit c59bdaf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 51 deletions.
52 changes: 2 additions & 50 deletions ipa-core/src/helpers/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,13 @@ use thiserror::Error;

use crate::{
error::BoxError,
helpers::{ChannelId, HelperChannelId, HelperIdentity, Role, TotalRecords, TransportIdentity},
protocol::{step::Gate, RecordId},
helpers::{ChannelId, TotalRecords, TransportIdentity},
protocol::RecordId,
};

/// An error raised by the IPA supporting infrastructure.
#[derive(Error, Debug)]
pub enum Error<I: TransportIdentity> {
#[error("An error occurred while sending data to {channel:?}: {inner}")]
SendError {
channel: ChannelId<I>,

#[source]
inner: BoxError,
},
#[error("An error occurred while sending data to unknown helper: {inner}")]
PollSendError {
#[source]
inner: BoxError,
},
#[error("An error occurred while receiving data from {source:?}/{step}: {inner}")]
ReceiveError {
source: I,
Expand All @@ -33,46 +21,10 @@ pub enum Error<I: TransportIdentity> {
// TODO(mt): add more fields, like step and role.
record_id: RecordId,
},
#[error("An error occurred while serializing or deserializing data for {record_id:?} and step {step}: {inner}")]
SerializationError {
record_id: RecordId,
step: String,
#[source]
inner: BoxError,
},
#[error("Encountered unknown identity {0:?}")]
UnknownIdentity(HelperIdentity),
#[error("record ID {record_id:?} is out of range for {channel_id:?} (expected {total_records:?} records)")]
TooManyRecords {
record_id: RecordId,
channel_id: ChannelId<I>,
total_records: TotalRecords,
},
}

impl Error<Role> {
pub fn send_error<E: Into<Box<dyn std::error::Error + Send + Sync + 'static>>>(
channel: HelperChannelId,
inner: E,
) -> Self {
Self::SendError {
channel,
inner: inner.into(),
}
}

#[must_use]
pub fn serialization_error<E: Into<BoxError>>(
record_id: RecordId,
gate: &Gate,
inner: E,
) -> Self {
Self::SerializationError {
record_id,
step: String::from(gate.as_ref()),
inner: inner.into(),
}
}
}

pub type Result<T> = std::result::Result<T, Error<Role>>;
2 changes: 1 addition & 1 deletion ipa-core/src/helpers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::ops::{Index, IndexMut};
/// to validate that transport can actually send streams of this type
#[cfg(test)]
pub use buffers::OrderingSender;
pub use error::{Error, Result};
pub use error::Error;

#[cfg(feature = "stall-detection")]
mod gateway_exports {
Expand Down

0 comments on commit c59bdaf

Please sign in to comment.