Skip to content

Commit

Permalink
Use Go 1.13 error wrapping
Browse files Browse the repository at this point in the history
In order to allow more context for error messages.
  • Loading branch information
zdevaty committed Feb 26, 2024
1 parent e27ebe9 commit f34b2e3
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
package tools

import (
"errors"

api "github.com/eliona-smart-building-assistant/go-eliona-api-client/v2"
"github.com/eliona-smart-building-assistant/go-utils/log"
)

func LogError(err error) {
if err != nil {
genErr, ok := err.(*api.GenericOpenAPIError)
if ok {
var genErr *api.GenericOpenAPIError
if errors.As(err, &genErr) {
log.Error("api", "Error requesting API: %v (Response: %v)", genErr.Error(), string(genErr.Body()))
} else {
log.Error("api", "Error requesting API: %v", err.Error())
Expand Down

0 comments on commit f34b2e3

Please sign in to comment.