Skip to content

Commit 31da225

Browse files
metalmatzeandreynering
authored andcommitted
Check unhandled errors (#128)
1 parent 24d7bae commit 31da225

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

main.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
package main
99

1010
import (
11+
"log"
1112
"os"
1213
"runtime"
1314

@@ -38,5 +39,5 @@ func main() {
3839
cmd.CmdAdmin,
3940
}
4041
app.Flags = append(app.Flags, []cli.Flag{}...)
41-
app.Run(os.Args)
42+
log.Fatal(app.Run(os.Args))
4243
}

routers/install.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
345345
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
346346
cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15))
347347

348-
os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
348+
err := os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
349+
if err != nil {
350+
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
351+
return
352+
}
353+
349354
if err := cfg.SaveTo(setting.CustomConf); err != nil {
350355
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
351356
return
@@ -375,8 +380,14 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
375380
}
376381

377382
// Auto-login for admin
378-
ctx.Session.Set("uid", u.ID)
379-
ctx.Session.Set("uname", u.Name)
383+
if err := ctx.Session.Set("uid", u.ID); err != nil {
384+
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
385+
return
386+
}
387+
if err := ctx.Session.Set("uname", u.Name); err != nil {
388+
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
389+
return
390+
}
380391
}
381392

382393
log.Info("First-time run install finished!")

0 commit comments

Comments
 (0)