uniform
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
@@ -60,12 +61,15 @@ func (k *KlarnaClient) getOrderResponse(res *http.Response) (*CheckoutOrder, err
|
||||
}
|
||||
return &klarnaOrderResponse, nil
|
||||
}
|
||||
body, err := io.ReadAll(res.Body)
|
||||
if err == nil {
|
||||
log.Println(string(body))
|
||||
body, readErr := io.ReadAll(res.Body)
|
||||
if len(body) > 0 {
|
||||
log.Printf("klarna error body: %s", string(body))
|
||||
return nil, fmt.Errorf("klarna: %s: %s", res.Status, string(bytes.TrimSpace(body)))
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("%s", res.Status)
|
||||
if readErr != nil {
|
||||
return nil, fmt.Errorf("klarna: %s (body unreadable: %v)", res.Status, readErr)
|
||||
}
|
||||
return nil, fmt.Errorf("klarna: %s", res.Status)
|
||||
}
|
||||
|
||||
func (k *KlarnaClient) CreateOrder(ctx context.Context, reader io.Reader) (*CheckoutOrder, error) {
|
||||
|
||||
Reference in New Issue
Block a user