fix: Implement From<SimulationError> for EncodingError

Took 6 minutes
This commit is contained in:
Diana Carvalho
2025-08-18 09:50:12 +01:00
parent 72b60aa324
commit 987956eb0b
2 changed files with 14 additions and 2 deletions

View File

@@ -1,6 +1,7 @@
use std::{io, str::Utf8Error};
use thiserror::Error;
use tycho_common::simulation::errors::SimulationError;
/// Represents the outer-level, user-facing errors of the tycho-execution encoding package.
///
@@ -41,3 +42,15 @@ impl From<Utf8Error> for EncodingError {
EncodingError::FatalError(err.to_string())
}
}
impl From<SimulationError> for EncodingError {
fn from(err: SimulationError) -> Self {
match err {
SimulationError::FatalError(err_msg) => EncodingError::FatalError(err_msg),
SimulationError::InvalidInput(err_msg, ..) => EncodingError::InvalidInput(err_msg),
SimulationError::RecoverableError(error_msg) => {
EncodingError::RecoverableError(error_msg)
}
}
}
}

View File

@@ -779,8 +779,7 @@ impl SwapEncoder for BebopSwapEncoder {
.request_signed_quote(params)
.await
})
})
.map_err(|e| EncodingError::FatalError(format!("Failed to get Bebop quote {e}")))?;
})?;
let bebop_calldata = signed_quote
.quote_attributes
.get("calldata")