From 890b5037a338c86b7b24f76c5f3ef2bad38bb380 Mon Sep 17 00:00:00 2001 From: prasad83 Date: Fri, 26 Sep 2025 14:51:37 +0530 Subject: [PATCH] Unmarshal should check error by status-code as well. For status code (500) - resp.Err was nil resp.Status was 500 INTERNAL SERVER ERROR Do(...).Into() was failing to unmarshal --- response.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/response.go b/response.go index 69aee12..ac083bd 100644 --- a/response.go +++ b/response.go @@ -180,6 +180,10 @@ func (r *Response) Unmarshal(v any) error { if r.Err != nil { return r.Err } + // error by status-code + if r.IsErrorState() { + return errors.New(r.Status) + } v = util.GetPointer(v) contentType := r.Header.Get("Content-Type") if strings.Contains(contentType, "json") {