Skip to content

Conversation

peterzen
Copy link
Member

@peterzen peterzen commented Aug 12, 2024

This change parses API error details from error responses.

@peterzen peterzen force-pushed the binance-api-req branch 2 times, most recently from 4adf0f7 to ac3a51c Compare September 14, 2024 13:54
Comment on lines -1920 to +1939
return dexnet.Do(req, thing, dexnet.WithSizeLimit(1<<24))
var sizeLimit int64 = 1 << 24

resp, err := http.DefaultClient.Do(req)
if err != nil {
return fmt.Errorf("error performing request: %w", err)
}
defer resp.Body.Close()
// https://binance-docs.github.io/apidocs/websocket_api/en/#response-format
if resp.StatusCode != http.StatusOK {
var apiResp BNApiResponse
reader := io.LimitReader(resp.Body, sizeLimit)
if err = json.NewDecoder(reader).Decode(&apiResp); err != nil {
return fmt.Errorf("error decoding response: %w", err)
}
return fmt.Errorf("API error %d: %s (%d)", resp.StatusCode, apiResp.Msg, apiResp.Code)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's just add this functionality to dexnet. 50005f4...buck54321:dexnet-errparse

@JoeGruffins
Copy link
Member

replaced by #3090

@JoeGruffins JoeGruffins closed this Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants