Skip to content

Commit f58d19e

Browse files
committed
rfq: add structured oracle error codes
Formalizes the 'Code' of an 'OracleError' as an 'OracleErrorCode', and adds a couple of values corresponding to structured error cases.
1 parent 3a7986f commit f58d19e

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

rfq/oracle.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,26 @@ const (
8686
// service.
8787
type OracleError struct {
8888
// Code is a code which uniquely identifies the error type.
89-
Code uint8
89+
Code OracleErrorCode
9090

9191
// Msg is a human-readable error message.
9292
Msg string
9393
}
9494

95+
// OracleErrorCode uniquely identifies the kinds of error an oracle may
96+
// return.
97+
type OracleErrorCode uint8
98+
99+
const (
100+
// ErrUnspecifiedOracleError represents the case where the oracle has
101+
// declined to give a more specific reason for the error.
102+
ErrUnspecifiedOracleError OracleErrorCode = iota
103+
104+
// ErrUnsupportedOracleAsset represents the case in which an oracle does
105+
// not provide quotes for the requested asset.
106+
ErrUnsupportedOracleAsset
107+
)
108+
95109
// Error returns a human-readable string representation of the error.
96110
func (o *OracleError) Error() string {
97111
// Sanitise price oracle error message by truncating to 255 characters.

0 commit comments

Comments
 (0)