Skip to content

Commit

Permalink
Fix unhandled null responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Aryan51203 committed Jan 1, 2025
1 parent d8b47d8 commit 5081abe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions helper/extracter.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package helper

import (
"encoding/json"
"errors"
"io"
"net/http"
"strconv"
Expand All @@ -25,6 +26,11 @@ func ExtractErrorCode(Error error) int {
}

func ExtractSuccessMessage(r *http.Response) string {

if r == nil {
log.ErrorLogger("Error message extractor failed: ", errors.New("response is nil"))
return "Kratos Connection Refused"
}

body, err := io.ReadAll(r.Body)

Expand Down Expand Up @@ -65,6 +71,11 @@ func ExtractSuccessMessage(r *http.Response) string {
}

func ExtractInfoMessage(r *http.Response) string {

if r == nil {
log.ErrorLogger("Error message extractor failed: ", errors.New("response is nil"))
return "Kratos Connection Refused"
}

body, err := io.ReadAll(r.Body)

Expand Down Expand Up @@ -106,6 +117,11 @@ func ExtractInfoMessage(r *http.Response) string {

func ExtractErrorMessage(r *http.Response) string {

if r == nil {
log.ErrorLogger("Error message extractor failed: ", errors.New("response is nil"))
return "Kratos Connection Refused"
}

body, err := io.ReadAll(r.Body)

if err != nil {
Expand Down

0 comments on commit 5081abe

Please sign in to comment.