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

This commit is contained in:
LinkinStar 2022-11-11 12:12:09 +08:00
parent 0c4eeda383
commit e00a03f2dd
4 changed files with 6 additions and 4 deletions

View File

@ -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)

View File

@ -97,6 +97,8 @@ backend:
database:
connection_failed:
other: "Database connection failed"
create_table_failed:
other: "Create table failed"
install:
create_config_failed:
other: "Cant create the config.yaml file."

View File

@ -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"
)

View File

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