Skip to content

Commit

Permalink
wip: error debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
Clement Liaw committed Jan 3, 2025
1 parent c62c317 commit 1606baa
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions internal/common/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/container-storage-interface/spec/lib/go/csi"
"k8s.io/klog/v2"

crusoeapi "github.com/crusoecloud/client-go/swagger/v1alpha5"
)
Expand Down Expand Up @@ -130,10 +131,14 @@ func GetAsyncOperationResult[T any](ctx context.Context, op *crusoeapi.Operation
// additional information which is present in the response. The error
// is returned unchanged if it cannot be unpacked.
func UnpackSwaggerErr(original error) error {
klog.Infof("original error: %v", original)
swagErr := &crusoeapi.GenericSwaggerError{}
if ok := errors.As(original, swagErr); !ok {
return original
}
klog.Infof("swagger error: %v", swagErr.Error())
klog.Infof("swagger body: %v", swagErr.Body())
klog.Infof("swagger model: %v", swagErr.Model())

var model crusoeapi.ErrorBody
err := json.Unmarshal(swagErr.Body(), &model)
Expand Down

0 comments on commit 1606baa

Please sign in to comment.