Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb2b5fe5

Browse files
committed
update errors thrown from the API
1 parent6c7b4d3 commitb2b5fe5

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

‎coderd/workspacebuilds.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ func (api *API) workspaceBuildByBuildNumber(rw http.ResponseWriter, r *http.Requ
166166
workspaceName:=chi.URLParam(r,"workspacename")
167167
buildNumber,err:=strconv.ParseInt(chi.URLParam(r,"buildnumber"),10,32)
168168
iferr!=nil {
169-
httpapi.Write(rw,http.StatusInternalServerError, httpapi.Response{
170-
Message:"Internal error parsing build number as integer.",
169+
httpapi.Write(rw,http.StatusBadRequest, httpapi.Response{
170+
Message:"Failed to parse build number as integer.",
171171
Detail:err.Error(),
172172
})
173173
return
@@ -177,14 +177,20 @@ func (api *API) workspaceBuildByBuildNumber(rw http.ResponseWriter, r *http.Requ
177177
OwnerID:owner.ID,
178178
Name:workspaceName,
179179
})
180-
180+
iferrors.Is(err,sql.ErrNoRows) {
181+
httpapi.Write(rw,http.StatusNotFound, httpapi.Response{
182+
Message:fmt.Sprintf("Workspace %q does not exist.",workspaceName),
183+
})
184+
return
185+
}
181186
iferr!=nil {
182187
httpapi.Write(rw,http.StatusInternalServerError, httpapi.Response{
183188
Message:"Internal error fetching workspace by name.",
184189
Detail:err.Error(),
185190
})
186191
return
187192
}
193+
188194
if!api.Authorize(rw,r,rbac.ActionRead,rbac.ResourceWorkspace.
189195
InOrg(workspace.OrganizationID).WithOwner(workspace.OwnerID.String()).WithID(workspace.ID.String())) {
190196
return
@@ -194,6 +200,12 @@ func (api *API) workspaceBuildByBuildNumber(rw http.ResponseWriter, r *http.Requ
194200
WorkspaceID:workspace.ID,
195201
BuildNumber:int32(buildNumber),
196202
})
203+
iferrors.Is(err,sql.ErrNoRows) {
204+
httpapi.Write(rw,http.StatusNotFound, httpapi.Response{
205+
Message:fmt.Sprintf("Workspace %q Build %q does not exist.",workspaceName,buildNumber),
206+
})
207+
return
208+
}
197209
iferr!=nil {
198210
httpapi.Write(rw,http.StatusInternalServerError, httpapi.Response{
199211
Message:"Internal error fetching workspace build.",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp