chore: update not found handler in deleting

This commit is contained in:
Steven
2022-09-03 18:54:22 +08:00
parent 43575e6f54
commit 4743818fe7
8 changed files with 40 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import (
"strconv"
"github.com/usememos/memos/api"
"github.com/usememos/memos/common"
"github.com/labstack/echo/v4"
)
@ -123,6 +124,9 @@ func (s *Server) registerShortcutRoutes(g *echo.Group) {
ID: shortcutID,
}
if err := s.Store.DeleteShortcut(ctx, shortcutDelete); err != nil {
if common.ErrorCode(err) == common.NotFound {
return echo.NewHTTPError(http.StatusNotFound, fmt.Sprintf("Shortcut ID not found: %d", shortcutID))
}
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to delete shortcut").SetInternal(err)
}