Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

migrate from failure to anyhow + thiserror #127

Merged
merged 7 commits into from
Feb 24, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ocd
  • Loading branch information
drunkirishcoder committed Feb 23, 2021
commit ec524ecadd0514ca02a2c86212c991d74114ff7c
2 changes: 1 addition & 1 deletion core/src/dpdk/kni.rs
Original file line number Diff line number Diff line change
@@ -233,7 +233,7 @@ unsafe impl Send for KniRx {}
unsafe impl Send for KniTx {}

/// KNI errors.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
pub(crate) enum KniError {
#[error("KNI is not enabled for the port.")]
Disabled,
2 changes: 1 addition & 1 deletion core/src/dpdk/mbuf.rs
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ impl SizeOf for ::std::net::Ipv6Addr {
}

/// Error indicating buffer access failures.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
pub(crate) enum BufferError {
/// The offset exceeds the buffer length.
#[error("Offset {0} exceeds the buffer length {1}.")]
2 changes: 1 addition & 1 deletion core/src/dpdk/mempool.rs
Original file line number Diff line number Diff line change
@@ -128,7 +128,7 @@ thread_local! {
}

/// Error indicating the `Mempool` is not found or is exhaused.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
pub(crate) enum MempoolError {
#[error("Cannot allocate a new mbuf from mempool")]
Exhausted,
2 changes: 1 addition & 1 deletion core/src/dpdk/mod.rs
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ use thiserror::Error;
/// An error generated in `libdpdk`.
///
/// When an FFI call fails, the `errno` is translated into `DpdkError`.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
#[error("{0}")]
pub(crate) struct DpdkError(String);

2 changes: 1 addition & 1 deletion core/src/dpdk/port.rs
Original file line number Diff line number Diff line change
@@ -258,7 +258,7 @@ impl PortQueue {
}

/// Error indicating failed to initialize the port.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
pub(crate) enum PortError {
/// Port is not found.
#[error("Port {0} is not found.")]
2 changes: 1 addition & 1 deletion core/src/net/cidr/mod.rs
Original file line number Diff line number Diff line change
@@ -27,7 +27,7 @@ pub use self::v6::Ipv6Cidr;
use thiserror::Error;

/// Error indicating that a CIDR range cannot be parsed or is handled with an invalid prefix length.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
pub enum CidrError {
/// Error returned when parsing a malformed CIDR range.
#[error("Failed to parse CIDR: {0}")]
2 changes: 1 addition & 1 deletion core/src/net/mac.rs
Original file line number Diff line number Diff line change
@@ -60,7 +60,7 @@ impl From<[u8; 6]> for MacAddr {
}

/// Error returned when parsing a malformed MAC address.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
#[error("Failed to parse '{0}' as MAC address.")]
pub struct MacParseError(String);

2 changes: 1 addition & 1 deletion core/src/packets/icmp/v4/mod.rs
Original file line number Diff line number Diff line change
@@ -160,7 +160,7 @@ impl fmt::Debug for Icmpv4 {
}

/// Error when trying to push a generic ICMPv4 header without a message body.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
#[error("Cannot push a generic ICMPv4 header without a message body.")]
pub struct NoIcmpv4MessageBody;

2 changes: 1 addition & 1 deletion core/src/packets/icmp/v6/mod.rs
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ impl<E: Ipv6Packet> fmt::Debug for Icmpv6<E> {
}

/// Error when trying to push a generic ICMPv6 header without a message body.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
#[error("Cannot push a generic ICMPv6 header without a message body.")]
pub struct NoIcmpv6MessageBody;

2 changes: 1 addition & 1 deletion core/src/packets/ip/mod.rs
Original file line number Diff line number Diff line change
@@ -266,7 +266,7 @@ impl fmt::Debug for Flow {
}

/// IP packet related errors.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
pub enum IpPacketError {
/// Error indicating mixing IPv4 and IPv6 addresses in a flow.
#[error("Cannot mix IPv4 and IPv6 addresses")]
2 changes: 1 addition & 1 deletion core/src/packets/ip/v6/srh.rs
Original file line number Diff line number Diff line change
@@ -492,7 +492,7 @@ impl<E: Ipv6Packet> Ipv6Packet for SegmentRouting<E> {
}

/// Error when the segment list length is 0.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
#[error("Segment list length must be greater than 0")]
pub struct BadSegmentsError;

2 changes: 1 addition & 1 deletion core/src/pcap.rs
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ const PCAP_SNAPSHOT_LEN: raw::c_int = ffi::RTE_MBUF_DEFAULT_BUF_SIZE as raw::c_i
///
/// When an FFI call fails, either a specified error message or an `errno` is
/// translated into a `PcapError`.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
#[error("{0}")]
struct PcapError(String);

2 changes: 1 addition & 1 deletion core/src/runtime/core_map.rs
Original file line number Diff line number Diff line change
@@ -149,7 +149,7 @@ pub(crate) struct CoreExecutor {
}

/// Core errors.
#[derive(Error, Debug)]
#[derive(Debug, Error)]
pub(crate) enum CoreError {
/// Core is not found.
#[error("{0:?} is not found.")]