diff --git a/cmd/ui/ui.go b/cmd/ui/ui.go index 4a7c582..eb3ab51 100644 --- a/cmd/ui/ui.go +++ b/cmd/ui/ui.go @@ -16,12 +16,15 @@ func HandleLogin(db *data.DB) http.HandlerFunc { id, err := db.GetID(user) if err != nil { + log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) - // TODO: und nun? + return } if err := db.CheckPassword(id, pass); err != nil { + log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) + return } else { template.Must(template.ParseFiles("web/templates/editor.html")).ExecuteTemplate(w, "page-content", nil) } @@ -36,8 +39,9 @@ func HandleFinishedEdit(f *feed.Feed) http.HandlerFunc { content, err := data.ConvertToHTML(mdContent) if err != nil { + log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) - log.Panicln(err) + return } feed.AddToFeed(f, title, desc, content) @@ -92,6 +96,7 @@ func HandleAddUser(db *data.DB) http.HandlerFunc { if err := db.AddUser(user, pass, first, last, writer, editor, admin); err != nil { log.Println(err) http.Error(w, err.Error(), http.StatusInternalServerError) + return } template.Must(template.ParseFiles("web/templates/editor.html")).Execute(w, nil) } diff --git a/main.go b/main.go index 5996983..b0bcfab 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "html/template" "log" "net/http" + "os" "streifling.com/jason/cpolis/cmd/data" "streifling.com/jason/cpolis/cmd/feed" @@ -11,6 +12,13 @@ import ( ) func main() { + logFile, err := os.Create("tmp/cpolis.log") + if err != nil { + log.Fatalln(err) + } + defer logFile.Close() + log.SetOutput(logFile) + db, err := data.OpenDB("cpolis") if err != nil { log.Fatalln(err)