Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #105 from bancodobrasil/fix/resolver-logs
Browse files Browse the repository at this point in the history
Fix/resolver logs
  • Loading branch information
ralphg6 authored Jul 5, 2024
2 parents 212c1ca + 698bc15 commit 1e287a2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ run-on-our-code-directories:
@make our-code-directories | xargs -n 1 $(ARGS)
our-code-directories:
@go list ./... | grep -v /docs
verify:test
make lint

verify:test lint

generate-swagger:
# Install swag on https://github.com/swaggo/swag
Expand Down
14 changes: 7 additions & 7 deletions types/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ func (c *Context) resolveImpl(resolver string, param string) interface{} {

err := json.NewEncoder(&buf).Encode(input)
if err != nil {
log.Panic("error on encode input")
log.WithError(err).Panic("error on encode input")
}

log.Tracef("Resolving with '%s' decoded: %v", url, buf.String())
Expand All @@ -309,7 +309,7 @@ func (c *Context) resolveImpl(resolver string, param string) interface{} {
}

if err != nil {
log.Panic("error on create Request")
log.WithError(err).Panic("error on create Request")
}

req.Header = config.ResolverBridgeHeaders
Expand All @@ -320,29 +320,29 @@ func (c *Context) resolveImpl(resolver string, param string) interface{} {

resp, err := Client.Do(req)
if err != nil {
log.Panic("error on execute request")
log.WithError(err).Panic("error on execute request")
}
defer resp.Body.Close()

data, err := io.ReadAll(resp.Body)
if err != nil {
log.Panic("error on read the body")
log.WithError(err).Panic("error on read the body")
}

log.Tracef("Resolving with '%s': %v > %s", url, input, string(data))

output := resolveOutputV1{}
err = json.Unmarshal(data, &output)
if err != nil {
log.Panic("error on response decoding")
log.WithError(err).Panic("error on response decoding")
}

if len(output.Errors) > 0 {
log.Panic(fmt.Sprintf("%s", output.Errors))
log.WithField("errors", output.Errors).Panic(fmt.Sprintf("%s", output.Errors))
}

if output.Error != "" {
panic(output.Error)
log.WithField("error", output.Error).Panic(output.Error)
}

return output.Context[param]
Expand Down
2 changes: 1 addition & 1 deletion types/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ func (m *MockHTTPClientUnexpectedError) Do(req *http.Request) (*http.Response, e
func TestResolveUnexpectedError(t *testing.T) {
defer func() {
r := recover()
if r != "error message" {
if (r.(*logrus.Entry)).Message != "error message" {
t.Error("The panic message it's not throwed")
}
}()
Expand Down

0 comments on commit 1e287a2

Please sign in to comment.