feat: Add EncodingError

Change method signatures to expect it and raise it where it makes sense

--- don't change below this line ---
ENG-4076 <#DTT#>
This commit is contained in:
Diana Carvalho
2025-01-17 13:18:28 +00:00
parent e77a50b2bb
commit bab5caa6f8
12 changed files with 100 additions and 38 deletions

View File

@@ -3,7 +3,10 @@ use std::{collections::HashMap, fs};
use serde::Deserialize;
use tycho_core::dto::Chain;
use crate::encoding::{evm::swap_encoder::builder::SwapEncoderBuilder, swap_encoder::SwapEncoder};
use crate::encoding::{
errors::EncodingError, evm::swap_encoder::builder::SwapEncoderBuilder,
swap_encoder::SwapEncoder,
};
pub struct SwapEncoderRegistry {
encoders: HashMap<String, Box<dyn SwapEncoder>>,
@@ -40,7 +43,7 @@ pub struct Config {
}
impl Config {
pub fn from_file(path: &str) -> Result<Self, anyhow::Error> {
pub fn from_file(path: &str) -> Result<Self, EncodingError> {
let config_str = fs::read_to_string(path)?;
let config: Config = serde_json::from_str(&config_str)?;
Ok(config)