From 0e458847e7b488d2aa514a9f45f911cd05ae93e7 Mon Sep 17 00:00:00 2001 From: xoy Date: Sat, 28 Jan 2023 18:44:11 +0100 Subject: [PATCH] fehlerbehebung --- database.go | 4 ++-- events.go | 2 +- file.go | 2 +- func.go | 10 +++++----- http.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/database.go b/database.go index e62cabf..b9ff63d 100644 --- a/database.go +++ b/database.go @@ -8,7 +8,7 @@ func dbConnect(username string, password string, address string, port string, da db, err := sql.Open("mysql", username+":"+password+"@tcp("+address+":"+port+")/"+database) if err != nil { - panic(err) + panic(err.Error()) } return db @@ -21,7 +21,7 @@ func dbClose(database *sql.DB) { func dbQuerry(database *sql.DB, sqlCode string) *sql.Rows { results, err := database.Query("SELECT id, name FROM tags") if err != nil { - panic(err) + panic(err.Error()) } return results diff --git a/events.go b/events.go index 5f8c0d0..fde085a 100644 --- a/events.go +++ b/events.go @@ -11,7 +11,7 @@ func getEvents() []event { Event := new(event) err := rows.Scan(&Event.id, &Event.title, &Event.description, &Event.media, &Event.date) if err != nil { - panic(err) + panic(err.Error()) } events = append(events, *Event) } diff --git a/file.go b/file.go index 32fcd94..6648025 100644 --- a/file.go +++ b/file.go @@ -9,7 +9,7 @@ func fileRead(src string) string { content, err := ioutil.ReadFile(src) if err != nil { - log.Fatal(err) + log.Fatal(err.Error()) } return string(content) diff --git a/func.go b/func.go index 7a815c6..54835b0 100644 --- a/func.go +++ b/func.go @@ -70,13 +70,13 @@ func getRoomState() status { c := &http.Client{Timeout: 10 * time.Second} r, err := c.Get("https://status.ctdo.de/api/simple/v2") if err != nil { - panic(err) + panic(err.Error()) } defer r.Body.Close() body, _err := io.ReadAll(r.Body) if _err != nil { - panic(_err) + panic(_err.Error()) } bodyString := string(body) @@ -99,7 +99,7 @@ func getRoomState() status { var __err error roomState.power, __err = strconv.ParseInt(temp[2], 0, 64) if __err != nil { - panic(__err) + panic(__err.Error()) } return *roomState @@ -188,12 +188,12 @@ func getNextTopic() topic { if newDate[0] == "Thu" || newDate[0] == "Tue" { dayA, errA := strconv.Atoi(newDate[2]) if errA != nil { - panic(errA) + panic(errA.Error()) } dayB, errB := strconv.Atoi(newDate[2]) if errB != nil { - panic(errB) + panic(errB.Error()) } if ifFloatRange(float64(dayA)/7, 0, 1, false, true) || (ifFloatRange(float64(dayB)/7, 2, 3, false, true) && newDate[0] == "Tue") { diff --git a/http.go b/http.go index df936b0..b72c771 100644 --- a/http.go +++ b/http.go @@ -21,7 +21,7 @@ func httpHandleFuncWithPOST(urlPath string, filepath string, contentType string) http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { if err := r.ParseForm(); err != nil { - panic(err) + panic(err.Error()) } }