Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Use full sentence when returing the echo http error
天舟c8e68ac491c1
diff --git a/backend/server/auth.go b/backend/server/auth.goindex be25202e26..f16f6b7b6f 100644--- a/backend/server/auth.go+++ b/backend/server/auth.go@@ -15,7 +15,7 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {g.POST("/auth/login", func(c echo.Context) error {login := &api.Login{}if err := jsonapi.UnmarshalPayload(c.Request().Body, login); err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "malformatted login request").SetInternal(err)+ return echo.NewHTTPError(http.StatusBadRequest, "Malformatted login request.").SetInternal(err)}user, err := s.PrincipalService.FindPrincipalByEmail(context.Background(), login.Email)@@ -23,24 +23,24 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {if bytebase.ErrorCode(err) == bytebase.ENOTFOUND {return echo.NewHTTPError(http.StatusUnauthorized, bytebase.ErrorMessage(err))}- return echo.NewHTTPError(http.StatusInternalServerError, "failed to authenticate user").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to authenticate user.").SetInternal(err)}// Compare the stored hashed password, with the hashed version of the password that was received.if err := bcrypt.CompareHashAndPassword([]byte(user.PasswordHash), []byte(login.Password)); err != nil {// If the two passwords don't match, return a 401 status.- return echo.NewHTTPError(http.StatusUnauthorized, "incorrect password").SetInternal(err)+ return echo.NewHTTPError(http.StatusUnauthorized, "Incorrect password.").SetInternal(err)}// If password is correct, generate tokens and set cookies.if err := GenerateTokensAndSetCookies(user, c); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "failed to generate access token").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to generate access token.").SetInternal(err)}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)c.Response().WriteHeader(http.StatusOK)if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "failed to marshal login response").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal login response.").SetInternal(err)}return nil@@ -49,12 +49,12 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {g.POST("/auth/signup", func(c echo.Context) error {signup := &api.Signup{}if err := jsonapi.UnmarshalPayload(c.Request().Body, signup); err != nil {- return echo.NewHTTPError(http.StatusBadRequest, "malformatted signup request").SetInternal(err)+ return echo.NewHTTPError(http.StatusBadRequest, "Malformatted signup request").SetInternal(err)}passwordHash, err := bcrypt.GenerateFromPassword([]byte(signup.Password), bcrypt.DefaultCost)if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "failed to generate password hash").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to generate password hash.").SetInternal(err)}principalCreate := &api.PrincipalCreate{@@ -71,17 +71,17 @@ func (s *Server) registerAuthRoutes(g *echo.Group) {if bytebase.ErrorCode(err) == bytebase.ECONFLICT {return echo.NewHTTPError(http.StatusConflict, bytebase.ErrorMessage(err))}- return echo.NewHTTPError(http.StatusInternalServerError, "failed to signup user").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to signup user.").SetInternal(err)}if err := GenerateTokensAndSetCookies(user, c); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "failed to generate access token").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to generate access token.").SetInternal(err)}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)c.Response().WriteHeader(http.StatusOK)if err := jsonapi.MarshalPayload(c.Response().Writer, user); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "failed to marshal signup response").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal signup response.").SetInternal(err)}return nildiff --git a/backend/server/principal.go b/backend/server/principal.goindex 84b3c39adb..b696a6f121 100644--- a/backend/server/principal.go+++ b/backend/server/principal.go@@ -17,13 +17,13 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {g.GET("/principal", func(c echo.Context) error {list, err := s.PrincipalService.FindPrincipalList(context.Background())if err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "failed to fetch principal list").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to fetch principal list.").SetInternal(err)}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)c.Response().WriteHeader(http.StatusOK)if err := jsonapi.MarshalPayload(c.Response().Writer, list); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, "failed to marshal principal list response").SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, "Failed to marshal principal list response.").SetInternal(err)}return nil@@ -32,7 +32,7 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {g.GET("/principal/:id", func(c echo.Context) error {id, err := strconv.Atoi(c.Param("id"))if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("id"))).SetInternal(err)+ return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s.", c.Param("id"))).SetInternal(err)}principal, err := s.PrincipalService.FindPrincipalByID(context.Background(), id)@@ -40,13 +40,13 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {if bytebase.ErrorCode(err) == bytebase.ENOTFOUND {return echo.NewHTTPError(http.StatusNotFound, bytebase.ErrorMessage(err))}- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to fetch principal ID: %v", id)).SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to fetch principal ID: %v.", id)).SetInternal(err)}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)c.Response().WriteHeader(http.StatusOK)if err := jsonapi.MarshalPayload(c.Response().Writer, principal); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal principal ID response: %v", id)).SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to marshal principal ID response: %v.", id)).SetInternal(err)}return nil@@ -55,13 +55,13 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {g.PATCH("/principal/:id", func(c echo.Context) error {id, err := strconv.Atoi(c.Param("id"))if err != nil {- return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s", c.Param("id"))).SetInternal(err)+ return echo.NewHTTPError(http.StatusBadRequest, fmt.Sprintf("ID is not a number: %s.", c.Param("id"))).SetInternal(err)}principalPatch := &api.PrincipalPatch{UpdaterId: c.Get(GetPrincipalIdContextKey()).(int)}if err := jsonapi.UnmarshalPayload(c.Request().Body, principalPatch); err != nil {log.Println(err)- return echo.NewHTTPError(http.StatusBadRequest, "malformatted patch principal request").SetInternal(err)+ return echo.NewHTTPError(http.StatusBadRequest, "Malformatted patch principal request.").SetInternal(err)}principal, err := s.PrincipalService.PatchPrincipalByID(context.Background(), id, principalPatch)@@ -69,13 +69,13 @@ func (s *Server) registerPrincipalRoutes(g *echo.Group) {if bytebase.ErrorCode(err) == bytebase.ENOTFOUND {return echo.NewHTTPError(http.StatusNotFound, bytebase.ErrorMessage(err))}- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to patch principal ID: %v", id)).SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to patch principal ID: %v.", id)).SetInternal(err)}c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSONCharsetUTF8)c.Response().WriteHeader(http.StatusOK)if err := jsonapi.MarshalPayload(c.Response().Writer, principal); err != nil {- return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("failed to marshal principal ID response: %v", id)).SetInternal(err)+ return echo.NewHTTPError(http.StatusInternalServerError, fmt.Sprintf("Failed to marshal principal ID response: %v.", id)).SetInternal(err)}return nildiff --git a/backend/sqlite/sqlite.go b/backend/sqlite/sqlite.goindex 72e483bc2d..0a015b8416 100644--- a/backend/sqlite/sqlite.go+++ b/backend/sqlite/sqlite.go@@ -244,7 +244,7 @@ func FormatError(err error) error {switch err.Error() {case "UNIQUE constraint failed: principal.email":- return bytebase.Errorf(bytebase.ECONFLICT, "email already exists")+ return bytebase.Errorf(bytebase.ECONFLICT, "Email already exists.")default:return err}