add check for api call failure
This commit is contained in:
parent
1d27a88908
commit
6a36bc43b5
@ -829,6 +829,7 @@ func (h *Handlers) ValidateAmount(ctx context.Context, sym string, input []byte)
|
|||||||
}
|
}
|
||||||
|
|
||||||
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
flag_invalid_amount, _ := h.flagManager.GetFlag("flag_invalid_amount")
|
||||||
|
flag_api_error, _ := h.flagManager.GetFlag("flag_api_call_error")
|
||||||
|
|
||||||
store := h.userdataStore
|
store := h.userdataStore
|
||||||
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
publicKey, _ := store.ReadEntry(ctx, sessionId, utils.DATA_PUBLIC_KEY)
|
||||||
@ -838,10 +839,15 @@ func (h *Handlers) ValidateAmount(ctx context.Context, sym string, input []byte)
|
|||||||
balanceRes, err := h.accountService.CheckBalance(string(publicKey))
|
balanceRes, err := h.accountService.CheckBalance(string(publicKey))
|
||||||
balanceStr := balanceRes.Result.Balance
|
balanceStr := balanceRes.Result.Balance
|
||||||
|
|
||||||
|
if !balanceRes.Ok {
|
||||||
|
res.FlagSet = append(res.FlagSet, flag_api_error)
|
||||||
|
return res, nil
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return res, err
|
return res, err
|
||||||
}
|
}
|
||||||
res.Content = balanceStr
|
res.Content = balanceStr
|
||||||
|
res.FlagReset = append(res.FlagReset, flag_api_error)
|
||||||
|
|
||||||
// Parse the balance
|
// Parse the balance
|
||||||
balanceParts := strings.Split(balanceStr, " ")
|
balanceParts := strings.Split(balanceStr, " ")
|
||||||
|
Loading…
Reference in New Issue
Block a user