From d9d2a1bee2c72e0d3c267e240654953b4367282f Mon Sep 17 00:00:00 2001 From: Cassandra Heart Date: Wed, 19 Apr 2023 21:23:27 -0500 Subject: [PATCH] handle non-200 status codes --- bootstrap.go | 17 ++++++++++++++++- main.go | 2 +- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/bootstrap.go b/bootstrap.go index d784af4..790ecbf 100644 --- a/bootstrap.go +++ b/bootstrap.go @@ -98,10 +98,14 @@ func JoinLobby() { if err != nil { panic(err) } else { - _, err := io.ReadAll(resp.Body) + responseData, err := io.ReadAll(resp.Body) if err != nil { panic(err) } else { + if resp.StatusCode != 200 { + fmt.Printf("Status code %d given by sequencer: \n", resp.StatusCode) + panic(string(responseData)) + } return } } @@ -125,6 +129,12 @@ func GetSequencerState() string { if err != nil { panic(err) } + + if resp.StatusCode != 200 { + fmt.Printf("Status code %d given by sequencer: \n", resp.StatusCode) + panic(string(sequencerState)) + } + return string(sequencerState) } @@ -144,6 +154,11 @@ func Bootstrap() { bcjBytes, err := io.ReadAll(bcjRes.Body) if err != nil { panic(err) + } else { + if bcjRes.StatusCode != 200 { + fmt.Printf("Status code %d given by sequencer: \n", bcjRes.StatusCode) + panic(string(bcjBytes)) + } } if err := json.Unmarshal(bcjBytes, bcj); err != nil { diff --git a/main.go b/main.go index 73e1d5e..27d2c27 100644 --- a/main.go +++ b/main.go @@ -104,7 +104,7 @@ func PrintLogo() { func PrintVersion() { fmt.Println(" ") - fmt.Println(" Quilibrium Ceremony Client - CLI - v1.0.1") + fmt.Println(" Quilibrium Ceremony Client - CLI - v1.0.2") fmt.Println() fmt.Println() }