Skip to content

Commit 2f096e2

Browse files
committed
rfq: relay error code in oracle response
Ensure the error code is part of an OracleError response, and pass the error intact in query{Bid,Ask}FromPriceOracle, instead of formatting it as a string.
1 parent f58d19e commit 2f096e2

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

rfq/negotiator.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,9 @@ func (n *Negotiator) queryBuyFromPriceOracle(assetSpecifier asset.Specifier,
146146
}
147147

148148
// Now we will check for an error in the response from the price oracle.
149-
// If present, we will convert it to a string and return it as an error.
149+
// If present, we will simply relay it.
150150
if oracleResponse.Err != nil {
151-
return nil, fmt.Errorf("failed to query price oracle for "+
152-
"buy price: %s", oracleResponse.Err)
151+
return nil, oracleResponse.Err
153152
}
154153

155154
// By this point, the price oracle did not return an error or a buy
@@ -282,10 +281,9 @@ func (n *Negotiator) querySellFromPriceOracle(assetSpecifier asset.Specifier,
282281
}
283282

284283
// Now we will check for an error in the response from the price oracle.
285-
// If present, we will convert it to a string and return it as an error.
284+
// If present, we will simply relay it.
286285
if oracleResponse.Err != nil {
287-
return nil, fmt.Errorf("failed to query price oracle for "+
288-
"sell price: %s", oracleResponse.Err)
286+
return nil, oracleResponse.Err
289287
}
290288

291289
// By this point, the price oracle did not return an error or a sell

rfq/oracle.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ func (r *RpcPriceOracle) QuerySellPrice(ctx context.Context,
370370

371371
return &OracleResponse{
372372
Err: &OracleError{
373-
Msg: result.Error.Message,
373+
Msg: result.Error.Message,
374+
Code: OracleErrorCode(result.Error.Code),
374375
},
375376
}, nil
376377

@@ -481,7 +482,8 @@ func (r *RpcPriceOracle) QueryBuyPrice(ctx context.Context,
481482

482483
return &OracleResponse{
483484
Err: &OracleError{
484-
Msg: result.Error.Message,
485+
Msg: result.Error.Message,
486+
Code: OracleErrorCode(result.Error.Code),
485487
},
486488
}, nil
487489

0 commit comments

Comments
 (0)