Skip to content

Commit

Permalink
Improved errors conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
mstrug committed Dec 11, 2024
1 parent c61f4bc commit ebd3e3b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions crates/orderbook/src/database/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ impl OrderWithQuote {
buy_amount: u256_to_big_decimal(&quote.buy_amount),
solver: ByteArray(quote.data.solver.0),
verified: quote.data.verified,
metadata: quote.data.metadata.try_into().map_err(
|e: serde_json::Error| {
AddOrderError::MetadataSerializationFailed(e.into())
},
)?,
metadata: quote
.data
.metadata
.try_into()
.map_err(AddOrderError::MetadataSerializationFailed)?,
})
})
.transpose()?,
Expand Down
4 changes: 2 additions & 2 deletions crates/orderbook/src/orderbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub enum AddOrderError {
existing: String,
},
#[error("quote metadata failed to serialize as json, error: {0}")]
MetadataSerializationFailed(#[source] anyhow::Error),
MetadataSerializationFailed(serde_json::Error),
}

impl AddOrderError {
Expand All @@ -164,7 +164,7 @@ impl AddOrderError {
},
},
InsertionError::MetadataSerializationFailed(err) => {
AddOrderError::MetadataSerializationFailed(err.into())
AddOrderError::MetadataSerializationFailed(err)
}
}
}
Expand Down

0 comments on commit ebd3e3b

Please sign in to comment.