Skip to content

Commit

Permalink
Log less
Browse files Browse the repository at this point in the history
  • Loading branch information
Sneagan committed Nov 20, 2024
1 parent 38efbd6 commit dbdb02f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions libs/wallet/provider/uphold/uphold.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"net/http/httputil"
"net/url"
"os"
"regexp"
"strconv"
"strings"
"time"
Expand Down Expand Up @@ -236,25 +237,31 @@ func submit(
if err != nil {
return nil, resp, fmt.Errorf("%w: %s", errorutils.ErrFailedBodyRead, err.Error())
}
sbody := string(body)
for _, p := range []string{`"description":\s*"[^"]+"\s*,?`, `"\w+Country":\s*"[^"]+"\s*,?`} {
re := regexp.MustCompile(p)
sbody = re.ReplaceAllString(sbody, "")
}
sbody = regexp.MustCompile(`,}`).ReplaceAllString(sbody, "}")

if logger != nil {
logger.Debug().
Str("path", "github.com/brave-intl/bat-go/wallet/provider/uphold").
Str("type", "http.Response").
Int("status", resp.StatusCode).
Str("headers", string(jsonHeaders)).
Msg(string(body))
Msg(sbody)
}

if resp.StatusCode/100 != 2 {
var uhErr upholdError
if json.Unmarshal(body, &uhErr) != nil {
return nil, resp, fmt.Errorf("Error %d, %s", resp.StatusCode, body)
if json.Unmarshal([]byte(sbody), &uhErr) != nil {
return nil, resp, fmt.Errorf("Error %d, %s", resp.StatusCode, sbody)
}
uhErr.RequestID = resp.Header.Get("Request-Id")
return nil, resp, uhErr
}
return body, resp, nil
return []byte(sbody), resp, nil
}

type createCardRequest struct {
Expand Down

0 comments on commit dbdb02f

Please sign in to comment.