summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Loibl <mail@matthiasloibl.com>2016-11-10 11:02:01 +0100
committerAndrey Nering <andrey.nering@gmail.com>2016-11-10 08:02:01 -0200
commit31da22530968a7dda7e8cb04c8765a431bea731e (patch)
treed3e23b9aa06b1288a121f8db8372a8f175693543
parent24d7bae2b25f855446ced0a40d9fc642f22bb984 (diff)
downloadgitea-31da22530968a7dda7e8cb04c8765a431bea731e.tar.gz
gitea-31da22530968a7dda7e8cb04c8765a431bea731e.zip
Check unhandled errors (#128)
-rw-r--r--main.go3
-rw-r--r--routers/install.go17
2 files changed, 16 insertions, 4 deletions
diff --git a/main.go b/main.go
index f077b5ec31..0ad5b8c3b9 100644
--- a/main.go
+++ b/main.go
@@ -8,6 +8,7 @@
package main
import (
+ "log"
"os"
"runtime"
@@ -38,5 +39,5 @@ func main() {
cmd.CmdAdmin,
}
app.Flags = append(app.Flags, []cli.Flag{}...)
- app.Run(os.Args)
+ log.Fatal(app.Run(os.Args))
}
diff --git a/routers/install.go b/routers/install.go
index 35728c3ca9..36293b1030 100644
--- a/routers/install.go
+++ b/routers/install.go
@@ -345,7 +345,12 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
cfg.Section("security").Key("INSTALL_LOCK").SetValue("true")
cfg.Section("security").Key("SECRET_KEY").SetValue(base.GetRandomString(15))
- os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
+ err := os.MkdirAll(filepath.Dir(setting.CustomConf), os.ModePerm)
+ if err != nil {
+ ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
+ return
+ }
+
if err := cfg.SaveTo(setting.CustomConf); err != nil {
ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
return
@@ -375,8 +380,14 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
}
// Auto-login for admin
- ctx.Session.Set("uid", u.ID)
- ctx.Session.Set("uname", u.Name)
+ if err := ctx.Session.Set("uid", u.ID); err != nil {
+ ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
+ return
+ }
+ if err := ctx.Session.Set("uname", u.Name); err != nil {
+ ctx.RenderWithErr(ctx.Tr("install.save_config_failed", err), INSTALL, &form)
+ return
+ }
}
log.Info("First-time run install finished!")