Skip to content

Commit

Permalink
Add better error log for failing http requests
Browse files Browse the repository at this point in the history
  • Loading branch information
tenjaa committed Jul 19, 2021
1 parent 4ad5b00 commit b95007f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import (
"crypto/x509"
"encoding/json"
"encoding/pem"
"fmt"
"gopkg.in/square/go-jose.v2"
"gopkg.in/square/go-jose.v2/jwt"
"net/http"
"os"
"strconv"
"time"
)
Expand Down Expand Up @@ -52,6 +54,8 @@ func GenerateAccessToken(s *Source, now time.Time) (string, error) {
var ir InstallationResponse
err = json.NewDecoder(installationResponse.Body).Decode(&ir)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, fmt.Sprintf("Error decoding installation response with status %d", installationResponse.StatusCode))
_, _ = fmt.Fprintln(os.Stderr, installationResponse.Body)
panic(err)
}

Expand All @@ -60,6 +64,8 @@ func GenerateAccessToken(s *Source, now time.Time) (string, error) {
var tr TokenResponse
err = json.NewDecoder(tokenResponse.Body).Decode(&tr)
if err != nil {
_, _ = fmt.Fprintln(os.Stderr, fmt.Sprintf("Error decoding token response with status %d", tokenResponse.StatusCode))
_, _ = fmt.Fprintln(os.Stderr, tokenResponse.Body)
panic(err)
}

Expand Down

0 comments on commit b95007f

Please sign in to comment.