diff --git a/internal/server/api/v1/repos/lock.go b/internal/server/api/v1/repos/lock.go index 607e9b74..c039f748 100644 --- a/internal/server/api/v1/repos/lock.go +++ b/internal/server/api/v1/repos/lock.go @@ -157,7 +157,7 @@ func (r *Repo) UpdateLock(c *gin.Context) { l, err := r.i.FindLockByID(ctx, id) if ent.IsNotFound(err) { r.log.Warn("The lock is not found.", zap.Error(err)) - gb.ErrorResponse(c, http.StatusUnprocessableEntity, "The lock is not found.") + gb.ErrorResponse(c, http.StatusNotFound, "The lock is not found.") return } else if err != nil { r.log.Error("It has failed to find the lock.", zap.Error(err)) @@ -200,7 +200,7 @@ func (r *Repo) DeleteLock(c *gin.Context) { l, err := r.i.FindLockByID(ctx, id) if ent.IsNotFound(err) { r.log.Warn("The lock is not found.", zap.Error(err)) - gb.ErrorResponse(c, http.StatusUnprocessableEntity, "The lock is not found.") + gb.ErrorResponse(c, http.StatusNotFound, "The lock is not found.") return } else if err != nil { r.log.Error("It has failed to find the lock.", zap.Error(err)) diff --git a/ui/src/apis/lock.ts b/ui/src/apis/lock.ts index f6585482..8fa279f9 100644 --- a/ui/src/apis/lock.ts +++ b/ui/src/apis/lock.ts @@ -3,7 +3,7 @@ import { StatusCodes } from "http-status-codes" import { instance, headers } from "./setting" import { _fetch } from "./_base" import { UserData, mapDataToUser } from "./user" -import { Lock, User, HttpForbiddenError, HttpUnprocessableEntityError } from "../models" +import { Lock, User, HttpForbiddenError, HttpNotFoundError, HttpUnprocessableEntityError } from "../models" interface LockData { id: number @@ -94,6 +94,11 @@ export const updateLock = async (namespace: string, name: string, id: number, pa throw new HttpForbiddenError(message) } + if (res.status === StatusCodes.NOT_FOUND) { + const {message} = await res.json() + throw new HttpNotFoundError(message) + } + const lock = res.json() .then(data => mapDataToLock(data)) return lock diff --git a/ui/src/redux/repoLock.ts b/ui/src/redux/repoLock.ts index 39fcc26b..3dfc1a2d 100644 --- a/ui/src/redux/repoLock.ts +++ b/ui/src/redux/repoLock.ts @@ -4,7 +4,8 @@ import { message } from "antd" import { Config, Lock, - HttpForbiddenError + HttpForbiddenError, + HttpNotFoundError } from "../models" import { getConfig, @@ -107,11 +108,18 @@ export const setAutoUnlock = createAsyncThunk