From e00a03f2dda5abeb5dfcda78e61091cc737620df Mon Sep 17 00:00:00 2001 From: LinkinStar Date: Fri, 11 Nov 2022 12:12:09 +0800 Subject: [PATCH] feat: modify the error information about the failure to create a table --- cmd/answer/main.go | 5 ++--- i18n/en_US.yaml | 2 ++ internal/base/reason/reason.go | 1 + internal/install/install_controller.go | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/cmd/answer/main.go b/cmd/answer/main.go index 37daf478..44ee2d10 100644 --- a/cmd/answer/main.go +++ b/cmd/answer/main.go @@ -32,13 +32,12 @@ var ( // @in header // @name Authorization func main() { + log.SetLogger(zap.NewLogger( + log.ParseLevel(logLevel), zap.WithName("answer"), zap.WithPath(logPath), zap.WithCallerFullPath())) Execute() } func runApp() { - log.SetLogger(zap.NewLogger( - log.ParseLevel(logLevel), zap.WithName("answer"), zap.WithPath(logPath), zap.WithCallerFullPath())) - c, err := conf.ReadConfig(cli.GetConfigFilePath()) if err != nil { panic(err) diff --git a/i18n/en_US.yaml b/i18n/en_US.yaml index 0ae83bf3..3c114988 100644 --- a/i18n/en_US.yaml +++ b/i18n/en_US.yaml @@ -97,6 +97,8 @@ backend: database: connection_failed: other: "Database connection failed" + create_table_failed: + other: "Create table failed" install: create_config_failed: other: "Can’t create the config.yaml file." diff --git a/internal/base/reason/reason.go b/internal/base/reason/reason.go index 74961d86..6765a883 100644 --- a/internal/base/reason/reason.go +++ b/internal/base/reason/reason.go @@ -40,6 +40,7 @@ const ( ReportNotFound = "error.report.not_found" ReadConfigFailed = "error.config.read_config_failed" DatabaseConnectionFailed = "error.database.connection_failed" + InstallCreateTableFailed = "error.database.create_table_failed" InstallConfigFailed = "error.install.create_config_failed" SiteInfoNotFound = "error.site_info.not_found" ) diff --git a/internal/install/install_controller.go b/internal/install/install_controller.go index 93ab5c08..d7f8ebac 100644 --- a/internal/install/install_controller.go +++ b/internal/install/install_controller.go @@ -170,7 +170,7 @@ func InitBaseInfo(ctx *gin.Context) { if err := migrations.InitDB(c.Data.Database); err != nil { log.Error("init database error: ", err.Error()) - handler.HandleResponse(ctx, errors.BadRequest(reason.DatabaseConnectionFailed), schema.ErrTypeAlert) + handler.HandleResponse(ctx, errors.BadRequest(reason.InstallCreateTableFailed), schema.ErrTypeAlert) return }