Skip to content

Commit e5b96d4

Browse files
committed
fix generic internal server error
1 parent 917997b commit e5b96d4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

coderd/insights.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,21 @@ func (api *API) insightsUserLatency(rw http.ResponseWriter, r *http.Request) {
9797
TemplateIDs: templateIDs,
9898
})
9999
if err != nil {
100-
httpapi.InternalServerError(rw, err)
100+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
101+
Message: "Internal error fetching user latency.",
102+
Detail: err.Error(),
103+
})
101104
return
102105
}
103106

104107
// Fetch all users so that we can still include users that have no
105108
// latency data.
106109
users, err := api.Database.GetUsers(ctx, database.GetUsersParams{})
107110
if err != nil {
108-
httpapi.InternalServerError(rw, err)
111+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
112+
Message: "Internal error fetching users.",
113+
Detail: err.Error(),
114+
})
109115
return
110116
}
111117

@@ -238,7 +244,10 @@ func (api *API) insightsTemplates(rw http.ResponseWriter, r *http.Request) {
238244
return nil
239245
}, nil)
240246
if err != nil {
241-
httpapi.InternalServerError(rw, err)
247+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
248+
Message: "Internal error fetching template insights.",
249+
Detail: err.Error(),
250+
})
242251
return
243252
}
244253

0 commit comments

Comments
 (0)