Skip to content

Commit

Permalink
Merge pull request #25 from cjh1/empty-response
Browse files Browse the repository at this point in the history
Add more descriptive message for EOF
  • Loading branch information
davidallendj authored Jun 25, 2024
2 parents 23646aa + 294e667 commit cdac4f1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion cmd/smd/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ package main
import (
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
"slices"

Expand Down Expand Up @@ -120,7 +122,15 @@ func (s *SmD) fetchPublicKeyFromURL(url string) error {
defer cancel()
set, err := jwk.Fetch(ctx, url, jwk.WithHTTPClient(client))
if err != nil {
return fmt.Errorf("%v", err)
msg := "%w"

// if the error tree contains an EOF, it means that the response was empty,
// so add a more descriptive message to the error tree
if errors.Is(err, io.EOF) {
msg = "received empty response for key: %w"
}

return fmt.Errorf(msg, err)
}
jwks, err := json.Marshal(set)
if err != nil {
Expand Down

0 comments on commit cdac4f1

Please sign in to comment.