Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit fc2446d

Browse files
committed
added more error context in middleware and display HTTP status debugging GH actions
1 parent 883f9ab commit fc2446d

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

db_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func GetResponseBody(t *testing.T, resp *http.Response) string {
8686
t.Fatal("error reading response body: ", err)
8787
}
8888

89-
return string(b)
89+
return fmt.Sprintf("HTTP Status:%s Error:%s", resp.Status, string(b))
9090
}
9191

9292
func TestHasPermission(t *testing.T) {

middleware/auth.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func RequireAuth(datastore internal.Persister, volatile internal.PubSuber) Middl
5555

5656
auth, err := ValidateAuthKey(datastore, volatile, ctx, key)
5757
if err != nil {
58+
err = fmt.Errorf("error validating auth key: %w", err)
5859
http.Error(w, err.Error(), http.StatusBadRequest)
5960
return
6061
}

middleware/withdb.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ func WithDB(datastore internal.Persister, volatile internal.PubSuber, g BillingP
4242
// let's try to see if they are allow to use a database
4343
conf, err = datastore.FindDatabase(key)
4444
if err != nil {
45+
err = fmt.Errorf("error finding database: %w", err)
4546
http.Error(w, err.Error(), http.StatusInternalServerError)
4647
return
4748
} else if !conf.IsActive {
4849
url, err := g(conf.CustomerID)
4950
if err != nil {
51+
err = fmt.Errorf("error generating billing portal: %w", err)
5052
http.Error(w, err.Error(), http.StatusInternalServerError)
5153
return
5254
}

0 commit comments

Comments
 (0)