mirror of
https://github.com/getAlby/hub.git
synced 2026-08-13 12:33:39 +02:00
Adding checks for ok status code in responses (#2178)
* fix: checks for ok status code in responses * refactor: replacing native fetch with useSWR * chore: remove url from logs * chore: add phoenixd error logs for non-success responses * chore: add use currencies hook * chore: use loading from currencies hook and filter out btc --------- Co-authored-by: im-adithya <imadithyavardhan@gmail.com>
This commit is contained in:
parent
895edabba7
commit
f2ea668df8
9 changed files with 205 additions and 67 deletions
|
|
@ -1273,6 +1273,15 @@ func (api *api) RequestMempoolApi(ctx context.Context, endpoint string) (interfa
|
|||
return nil, errors.New("failed to read response body")
|
||||
}
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
logger.Logger.WithFields(logrus.Fields{
|
||||
"endpoint": endpoint,
|
||||
"status_code": res.StatusCode,
|
||||
"body": string(body),
|
||||
}).Error("Mempool endpoint returned non-success code")
|
||||
return nil, fmt.Errorf("mempool endpoint returned non-success code: %s", string(body))
|
||||
}
|
||||
|
||||
var jsonContent interface{}
|
||||
jsonErr := json.Unmarshal(body, &jsonContent)
|
||||
if jsonErr != nil {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,15 @@ func (api *api) RequestEsploraApi(ctx context.Context, endpoint string) (interfa
|
|||
return nil, errors.New("failed to read response body")
|
||||
}
|
||||
|
||||
if res.StatusCode != http.StatusOK {
|
||||
logger.Logger.WithFields(logrus.Fields{
|
||||
"endpoint": endpoint,
|
||||
"status_code": res.StatusCode,
|
||||
"body": string(body),
|
||||
}).Error("Esplora endpoint returned non-success code")
|
||||
return nil, fmt.Errorf("esplora endpoint returned non-success code: %s", string(body))
|
||||
}
|
||||
|
||||
var jsonContent interface{}
|
||||
jsonErr := json.Unmarshal(body, &jsonContent)
|
||||
if jsonErr != nil {
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ func (api *api) RebalanceChannel(ctx context.Context, rebalanceChannelRequest *R
|
|||
return nil, errors.New("failed to read response body")
|
||||
}
|
||||
|
||||
if res.StatusCode >= 300 {
|
||||
if res.StatusCode != http.StatusOK {
|
||||
logger.Logger.WithFields(logrus.Fields{
|
||||
"request": newRspCreateOrderRequest,
|
||||
"body": string(body),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue