Skip to content

A Q&A platform software for teams at any scales. Whether it's a community forum, help center, or knowledge management platform, you can always count on Apache Answer.

feat: modify the error information about the failure to create a table

LinkinStare00a03f2dda5
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
}