Skip to content

Commit ec7979c

Browse files
committed
files.go: check error properly when fetching file
1 parent e20fac4 commit ec7979c

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

coderd/files.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,14 @@ func (api *API) postFile(rw http.ResponseWriter, r *http.Request) {
7676
ID: file.ID,
7777
})
7878
return
79+
} else if !errors.Is(err, sql.ErrNoRows) {
80+
httpapi.Write(ctx, rw, http.StatusInternalServerError, codersdk.Response{
81+
Message: "Internal error getting file.",
82+
Detail: err.Error(),
83+
})
84+
return
7985
}
86+
8087
id := uuid.New()
8188
file, err = api.Database.InsertFile(ctx, database.InsertFileParams{
8289
ID: id,

0 commit comments

Comments
 (0)