You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
api_endpoint! {
SUBMIT_TRANSACTION_ENDPOINT,
async |fedimint: &ConsensusApi, _context, transaction: SerdeTransaction| -> SerdeModuleEncoding<Result<TransactionId, TransactionError>> {
let transaction = transaction
.try_into_inner(&fedimint.modules.decoder_registry())
.map_err(|e| ApiError::bad_request(e.to_string()))?;
// we return an inner error if and only if the submitted transaction is
// invalid and will be rejected if we were to submit it to consensus
Ok((&fedimint.submit_transaction(transaction).await).into())
}
},
SerdeModuleEncoding<Result<TransactionId, TransactionError>>. That's terrible. Basically we encode the result using consensus encoding, making it impossible to evolve.
so we should just impl From<TransactionError> for ApiError, and convert every case to a specific code, and throw the to_string() of the error into a message.
This will break the backward compat, so we should just make a new call for it.
Generally the way we handle errors in api is terrible, AFAICT.
BTW. If ApiError::code is the jsonrpc error code, then we should use better values, as per https://www.jsonrpc.org/specification , not http codes (see impls for ApiError):
The remainder of the space is available for application defined errors.
The text was updated successfully, but these errors were encountered:
SerdeModuleEncoding<Result<TransactionId, TransactionError>>
. That's terrible. Basically we encode the result using consensus encoding, making it impossible to evolve.The top-level error is:
so we should just
impl From<TransactionError> for ApiError
, and convert every case to a specific code, and throw theto_string()
of the error into amessage
.This will break the backward compat, so we should just make a new call for it.
Generally the way we handle errors in api is terrible, AFAICT.
BTW. If
ApiError::code
is the jsonrpc error code, then we should use better values, as per https://www.jsonrpc.org/specification , not http codes (seeimpls
forApiError
):The text was updated successfully, but these errors were encountered: