Skip to content

Commit

Permalink
Improve CheckResponse usability
Browse files Browse the repository at this point in the history
Signed-off-by: arekkas <aeneas@ory.am>
  • Loading branch information
arekkas committed Oct 8, 2018
1 parent f9b8f03 commit 8ea5078
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmdx/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmdx
import (
"encoding/json"
"fmt"
"net/http"
"os"
)

Expand All @@ -15,11 +16,11 @@ func Must(err error, message string, args ...interface{}) {
os.Exit(1)
}

func CheckResponse(err error, expectedStatusCode, receivedStatusCode int) {
func CheckResponse(err error, expectedStatusCode int, response *http.Response) {
Must(err, "Command failed because error \"%s\" occurred.\n", err)

if receivedStatusCode != expectedStatusCode {
Fatalf("Command failed because status code %d was expected but code %d was received.\n", expectedStatusCode, receivedStatusCode)
if response.StatusCode != expectedStatusCode {
Fatalf("Command failed because status code %d was expected but code %d was received.\n", expectedStatusCode, response.StatusCode)
}
}

Expand Down

0 comments on commit 8ea5078

Please sign in to comment.