mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
ftx: handle err response
This commit is contained in:
parent
9c4ccbd6e2
commit
f345730778
|
@ -23,7 +23,11 @@ func (h *messageHandler) handleMessage(message []byte) {
|
|||
case privateOrdersChannel:
|
||||
h.handlePrivateOrders(r)
|
||||
default:
|
||||
logger.Errorf("unsupported message type: %+v", r.Type)
|
||||
if r.Type != errRespType {
|
||||
logger.Errorf("unsupported message type: %+v", r.Type)
|
||||
return
|
||||
}
|
||||
logger.Errorf("received err: %s", r.toErrResponse())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ Private:
|
|||
order: {"type": "subscribed", "channel": "orders"}
|
||||
|
||||
Public
|
||||
ordeerbook: {"type": "subscribed", "channel": "orderbook", "market": "BTC/USDT"}
|
||||
orderbook: {"type": "subscribed", "channel": "orderbook", "market": "BTC/USDT"}
|
||||
|
||||
*/
|
||||
type subscribedResponse struct {
|
||||
|
@ -154,6 +154,23 @@ func (r websocketResponse) toSubscribedResponse() (subscribedResponse, error) {
|
|||
}, nil
|
||||
}
|
||||
|
||||
// {"type": "error", "code": 400, "msg": "Already logged in"}
|
||||
type errResponse struct {
|
||||
Code int64 `json:"code"`
|
||||
Message string `json:"msg"`
|
||||
}
|
||||
|
||||
func (e errResponse) String() string {
|
||||
return fmt.Sprintf("%d: %s", e.Code, e.Message)
|
||||
}
|
||||
|
||||
func (r websocketResponse) toErrResponse() errResponse {
|
||||
return errResponse{
|
||||
Code: r.Code,
|
||||
Message: r.Message,
|
||||
}
|
||||
}
|
||||
|
||||
func (r websocketResponse) toPublicOrderBookResponse() (orderBookResponse, error) {
|
||||
if r.Channel != orderBookChannel {
|
||||
return orderBookResponse{}, fmt.Errorf("type %s, channel %s: %w", r.Type, r.Channel, errUnsupportedConversion)
|
||||
|
|
Loading…
Reference in New Issue
Block a user