Skip to content

Commit 79308a2

Browse files
committed
rfqmsg: use const/enum reject error codes
Defines specific consts for the two RejectErr error codes, and uses those in place of the raw uint8 values.
1 parent 6130dac commit 79308a2

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

rfqmsg/reject.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,29 @@ func (v *RejectErr) Record() tlv.Record {
7676
)
7777
}
7878

79+
const (
80+
// UnspecifiedRejectCode indicates that a request-for-quote was
81+
// rejected, without necessarily providing any further detail as to
82+
// why.
83+
UnspecifiedRejectCode uint8 = iota
84+
85+
// UnavailableRejectCode indicates that a request-for-quote was
86+
// rejected as a price oracle was unavailable.
87+
UnavailableRejectCode
88+
)
89+
7990
var (
8091
// ErrUnknownReject is the error code for when the quote is rejected
8192
// for an unspecified reason.
8293
ErrUnknownReject = RejectErr{
83-
Code: 0,
94+
Code: UnspecifiedRejectCode,
8495
Msg: "unknown reject error",
8596
}
8697

87-
// ErrPriceOracleUnavailable is the error code for when the price oracle
88-
// is unavailable.
98+
// ErrPriceOracleUnavailable is the error code for when the price
99+
// oracle is unavailable.
89100
ErrPriceOracleUnavailable = RejectErr{
90-
Code: 1,
101+
Code: UnavailableRejectCode,
91102
Msg: "price oracle unavailable",
92103
}
93104
)
@@ -96,7 +107,7 @@ var (
96107
// it with a custom error message.
97108
func ErrRejectWithCustomMsg(msg string) RejectErr {
98109
return RejectErr{
99-
Code: 0,
110+
Code: UnspecifiedRejectCode,
100111
Msg: msg,
101112
}
102113
}

0 commit comments

Comments
 (0)