Skip to content

Commit

Permalink
fix: Add coverage(off) to new error methods
Browse files Browse the repository at this point in the history
Signed-off-by: John Nunley <[email protected]>
  • Loading branch information
notgull committed May 19, 2024
1 parent a239fb6 commit 73a7564
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ pub enum Error {
}

impl fmt::Display for Error {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self {
Self::InvalidToken => f.write_str("invalid token provided to internal function"),
Expand All @@ -49,19 +50,22 @@ impl fmt::Display for Error {
}

impl From<std::io::Error> for Error {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn from(value: std::io::Error) -> Self {
Self::IoError(value)
}
}

impl From<Box<dyn std::error::Error + Sync + Send>> for Error {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn from(value: Box<dyn std::error::Error + Sync + Send>) -> Self {
Self::OtherError(value)
}
}

impl From<Error> for std::io::Error {
/// Converts Calloop's error type into a [`std::io::Error`].
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn from(err: Error) -> Self {
match err {
Error::IoError(source) => source,
Expand All @@ -72,6 +76,7 @@ impl From<Error> for std::io::Error {
}

impl std::error::Error for Error {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
match self {
Self::InvalidToken => None,
Expand Down Expand Up @@ -100,6 +105,7 @@ impl<T> Debug for InsertError<T> {
}

impl<T> fmt::Display for InsertError<T> {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(f, "error inserting event source: {}", &self.error)
}
Expand All @@ -115,6 +121,7 @@ impl<T> From<InsertError<T>> for crate::Error {
}

impl<T> std::error::Error for InsertError<T> {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(&self.error)
}
Expand Down
2 changes: 2 additions & 0 deletions src/sources/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,14 @@ impl<T> EventSource for Channel<T> {
pub struct ChannelError(PingError);

impl fmt::Display for ChannelError {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

impl std::error::Error for ChannelError {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(&self.0)
}
Expand Down
2 changes: 2 additions & 0 deletions src/sources/futures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ impl<T> Drop for Executor<T> {
pub struct ExecutorDestroyed;

impl fmt::Display for ExecutorDestroyed {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("the executor was destroyed")
}
Expand Down Expand Up @@ -389,6 +390,7 @@ pub enum ExecutorError {
}

impl fmt::Display for ExecutorError {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NewFutureError(err) => write!(f, "error adding new futures: {}", err),
Expand Down
2 changes: 2 additions & 0 deletions src/sources/ping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,14 @@ pub type PingSource = platform::PingSource;
pub struct PingError(Box<dyn std::error::Error + Sync + Send>);

impl fmt::Display for PingError {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

impl std::error::Error for PingError {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(&*self.0)
}
Expand Down
2 changes: 2 additions & 0 deletions src/sources/signals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,12 +336,14 @@ impl EventSource for Signals {
pub struct SignalError(Box<dyn std::error::Error + Sync + Send>);

impl fmt::Display for SignalError {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(&self.0, f)
}
}

impl std::error::Error for SignalError {
#[cfg_attr(feature = "nightly_coverage", coverage(off))]
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
Some(&*self.0)
}
Expand Down

0 comments on commit 73a7564

Please sign in to comment.