Verbessere Logging und Fehlerbehandlung
This commit is contained in:
parent
c737818ce4
commit
6e97d867de
14 changed files with 223 additions and 88 deletions
|
@ -3,6 +3,7 @@ package controllers
|
|||
import (
|
||||
"fmt"
|
||||
"html/template"
|
||||
"log"
|
||||
"net/http"
|
||||
"officeHours/models"
|
||||
"strconv"
|
||||
|
@ -19,7 +20,10 @@ func (b *BaseHandler) GetByRoomHandler(w http.ResponseWriter, req *http.Request)
|
|||
b.RootHandler(w, req)
|
||||
return
|
||||
}
|
||||
officeHours, _ := b.officeHourRepo.FindByRoom(room, true)
|
||||
officeHours, err := b.officeHourRepo.FindByRoom(room, true)
|
||||
if err != nil {
|
||||
log.Printf("Error getting office hours for room %s: %s", room.Name, err.Error())
|
||||
}
|
||||
timetable, slots := b.GetTimetable(officeHours)
|
||||
b.writeTimetablePage(w, req, b.printTimetable(timetable, slots, false))
|
||||
}
|
||||
|
@ -34,7 +38,10 @@ func (b *BaseHandler) GetByCourseHandler(w http.ResponseWriter, req *http.Reques
|
|||
b.RootHandler(w, req)
|
||||
return
|
||||
}
|
||||
officeHours, _ := b.officeHourRepo.FindByCourse(course, true)
|
||||
officeHours, err := b.officeHourRepo.FindByCourse(course, true)
|
||||
if err != nil {
|
||||
log.Printf("Error getting office hours for course %s: %s", course.Name, err.Error())
|
||||
}
|
||||
timetable, slots := b.GetTimetable(officeHours)
|
||||
b.writeTimetablePage(w, req, b.printTimetable(timetable, slots, false))
|
||||
}
|
||||
|
@ -51,9 +58,10 @@ func (b *BaseHandler) writeTimetablePage(w http.ResponseWriter, req *http.Reques
|
|||
SelectedRoom int
|
||||
SelectedCourse int
|
||||
}{courses, rooms, timetable, selectedRoom, selectedCourse}
|
||||
err := Templates.ExecuteTemplate(w, "index.html", data)
|
||||
if err != nil {
|
||||
w.Write([]byte(fmt.Sprintf("Template konnte nicht geparst werden : %s", err.Error())))
|
||||
templateError := Templates.ExecuteTemplate(w, "index.html", data)
|
||||
if templateError != nil {
|
||||
log.Printf("Error executing template index.html: %s", templateError.Error())
|
||||
w.Write([]byte(fmt.Sprintf("Template konnte nicht geparst werden : %s", templateError.Error())))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue