diff --git a/Database.go b/Database.go index c1f75c6..b8fe057 100644 --- a/Database.go +++ b/Database.go @@ -71,7 +71,7 @@ func getSnapshotRecordsFromDb(minuteAgo int) ([]*SnapshotRecord, error) { query := "SELECT `%s`, `%s`, `%s`, `%s`, `%s` FROM `snapshots` WHERE `%s` > date_sub(now(), interval %v minute) ORDER BY `id` DESC;" rows, err := ClimateDb.Query(fmt.Sprintf(query, "id", "temp", "humidity", "co2", "time", "time", minuteAgo)) if err != nil { - return nil, err + return nil, fmt.Errorf("couldn't execute select query: %w", err) } for rows.Next() { var snapshotRecord SnapshotRecord diff --git a/climate-server.go b/climate-server.go index 273d691..30ade44 100644 --- a/climate-server.go +++ b/climate-server.go @@ -1,6 +1,7 @@ package main import ( + "errors" "fmt" _ "github.com/go-sql-driver/mysql" "github.com/gorilla/mux" @@ -91,7 +92,7 @@ func saveSnapshot(w http.ResponseWriter, r *http.Request) { } func internalErrorOnErr(err error, w http.ResponseWriter, r *http.Request) bool { - if err != nil { + if errors.Unwrap(err) != nil { errorMessage := "Internal Server Error!" if DEBUG { errorMessage += fmt.Sprintf(" Happened during %s request for pattern '%s': %s",