mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-22 21:04:53 +01:00
chore: implement from ConnectionError and from RemoteError for AssertionError
This commit is contained in:
parent
dc627dc6af
commit
44e5e390eb
1 changed files with 22 additions and 0 deletions
|
@ -5,6 +5,7 @@ mod client;
|
|||
mod server;
|
||||
|
||||
pub mod fixtures;
|
||||
use crate::errors::{ConnectionError, RemoteError};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AssertionError(String);
|
||||
|
@ -23,6 +24,27 @@ impl std::fmt::Display for AssertionError {
|
|||
|
||||
impl std::error::Error for AssertionError {}
|
||||
|
||||
impl From<ConnectionError> for AssertionError {
|
||||
fn from(value: ConnectionError) -> Self {
|
||||
match value {
|
||||
ConnectionError::Transport(error) => AssertionError::new(&format!(
|
||||
"Connection::Transport error during setup of a test: {}",
|
||||
error,
|
||||
)),
|
||||
ConnectionError::Remote(remote_error) => AssertionError::new(&format!(
|
||||
"Connection::Remote error during setup of a test: {}",
|
||||
remote_error,
|
||||
)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<RemoteError> for AssertionError {
|
||||
fn from(value: RemoteError) -> Self {
|
||||
AssertionError::new(&format!("Remote error during setup of a test: {}", value,))
|
||||
}
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! assert_or_err {
|
||||
($s:expr) => {
|
||||
|
|
Loading…
Reference in a new issue