fehlerbehebung

This commit is contained in:
xoy 2023-01-28 18:44:11 +01:00
parent 6d073547d3
commit 0e458847e7
5 changed files with 10 additions and 10 deletions

View File

@ -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) db, err := sql.Open("mysql", username+":"+password+"@tcp("+address+":"+port+")/"+database)
if err != nil { if err != nil {
panic(err) panic(err.Error())
} }
return db return db
@ -21,7 +21,7 @@ func dbClose(database *sql.DB) {
func dbQuerry(database *sql.DB, sqlCode string) *sql.Rows { func dbQuerry(database *sql.DB, sqlCode string) *sql.Rows {
results, err := database.Query("SELECT id, name FROM tags") results, err := database.Query("SELECT id, name FROM tags")
if err != nil { if err != nil {
panic(err) panic(err.Error())
} }
return results return results

View File

@ -11,7 +11,7 @@ func getEvents() []event {
Event := new(event) Event := new(event)
err := rows.Scan(&Event.id, &Event.title, &Event.description, &Event.media, &Event.date) err := rows.Scan(&Event.id, &Event.title, &Event.description, &Event.media, &Event.date)
if err != nil { if err != nil {
panic(err) panic(err.Error())
} }
events = append(events, *Event) events = append(events, *Event)
} }

View File

@ -9,7 +9,7 @@ func fileRead(src string) string {
content, err := ioutil.ReadFile(src) content, err := ioutil.ReadFile(src)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err.Error())
} }
return string(content) return string(content)

10
func.go
View File

@ -70,13 +70,13 @@ func getRoomState() status {
c := &http.Client{Timeout: 10 * time.Second} c := &http.Client{Timeout: 10 * time.Second}
r, err := c.Get("https://status.ctdo.de/api/simple/v2") r, err := c.Get("https://status.ctdo.de/api/simple/v2")
if err != nil { if err != nil {
panic(err) panic(err.Error())
} }
defer r.Body.Close() defer r.Body.Close()
body, _err := io.ReadAll(r.Body) body, _err := io.ReadAll(r.Body)
if _err != nil { if _err != nil {
panic(_err) panic(_err.Error())
} }
bodyString := string(body) bodyString := string(body)
@ -99,7 +99,7 @@ func getRoomState() status {
var __err error var __err error
roomState.power, __err = strconv.ParseInt(temp[2], 0, 64) roomState.power, __err = strconv.ParseInt(temp[2], 0, 64)
if __err != nil { if __err != nil {
panic(__err) panic(__err.Error())
} }
return *roomState return *roomState
@ -188,12 +188,12 @@ func getNextTopic() topic {
if newDate[0] == "Thu" || newDate[0] == "Tue" { if newDate[0] == "Thu" || newDate[0] == "Tue" {
dayA, errA := strconv.Atoi(newDate[2]) dayA, errA := strconv.Atoi(newDate[2])
if errA != nil { if errA != nil {
panic(errA) panic(errA.Error())
} }
dayB, errB := strconv.Atoi(newDate[2]) dayB, errB := strconv.Atoi(newDate[2])
if errB != nil { 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") { if ifFloatRange(float64(dayA)/7, 0, 1, false, true) || (ifFloatRange(float64(dayB)/7, 2, 3, false, true) && newDate[0] == "Tue") {

View File

@ -21,7 +21,7 @@ func httpHandleFuncWithPOST(urlPath string, filepath string, contentType string)
http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/"+urlPath, func(w http.ResponseWriter, r *http.Request) {
if r.Method == "POST" { if r.Method == "POST" {
if err := r.ParseForm(); err != nil { if err := r.ParseForm(); err != nil {
panic(err) panic(err.Error())
} }
} }