77 "fmt"
88 "io"
99 "net/http"
10- "runtime/debug"
1110 "strings"
1211
1312 "github.com/deploymenttheory/go-api-http-client/logger"
@@ -49,20 +48,17 @@ func handleAPIErrorResponse(resp *http.Response, log logger.Logger) *APIError {
4948 return apiError
5049 }
5150
52- stackTrace := string (debug .Stack ())
53-
5451 // Check if the response is JSON
5552 if isJSONResponse (resp ) {
5653 // Attempt to parse the response into a StructuredError
5754 if err := json .Unmarshal (bodyBytes , & apiError ); err == nil && apiError .Message != "" {
58- stackTrace := string (debug .Stack ())
5955 log .LogError (
6056 "json_structured_error_detected" , // event
6157 resp .Request .Method , // method
6258 resp .Request .URL .String (), // url
6359 resp .StatusCode , // statusCode
6460 fmt .Errorf (apiError .Message ), // err
65- stackTrace , // stacktrace
61+ apiError . Raw , // raw resp
6662 )
6763 return apiError
6864 }
@@ -83,7 +79,7 @@ func handleAPIErrorResponse(resp *http.Response, log logger.Logger) *APIError {
8379 resp .Request .URL .String (), // url
8480 resp .StatusCode , // statusCode
8581 fmt .Errorf (apiError .Message ), // err
86- stackTrace , // stacktrace
82+ apiError . Raw , // raw resp
8783 )
8884 return apiError
8985 } else {
@@ -95,7 +91,7 @@ func handleAPIErrorResponse(resp *http.Response, log logger.Logger) *APIError {
9591 resp .Request .URL .String (), // url
9692 resp .StatusCode , // statusCode
9793 fmt .Errorf ("Non-JSON error response received" ), // err
98- stackTrace , // stacktrace
94+ apiError . Raw , // raw resp
9995 )
10096 return apiError
10197 }
0 commit comments