From bbec2d8ccf0c88c0f2ce02803b04c8a95220b6b5 Mon Sep 17 00:00:00 2001 From: simon987 Date: Fri, 3 Jan 2020 15:50:52 -0500 Subject: [PATCH] More error handling... --- api/worker.go | 8 +++++++- storage/worker.go | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/worker.go b/api/worker.go index de0f04c..d62ec71 100644 --- a/api/worker.go +++ b/api/worker.go @@ -185,9 +185,15 @@ func (api *WebAPI) WorkerSetPaused(r *Request) { } func (api *WebAPI) GetAllWorkerStats(r *Request) { - stats := api.Database.GetAllWorkerStats() + if stats == nil { + r.OkJson(JsonResponse{ + Ok: false, + }) + return + } + r.OkJson(JsonResponse{ Ok: true, Content: GetAllWorkerStatsResponse{ diff --git a/storage/worker.go b/storage/worker.go index b0c97e9..f6410c0 100644 --- a/storage/worker.go +++ b/storage/worker.go @@ -181,6 +181,9 @@ func (database *Database) GetAllWorkerStats() *[]WorkerStats { FROM worker WHERE closed_task_count>0 LIMIT 50`) handleErr(err) + if err != nil { + return nil + } stats := make([]WorkerStats, 0) for rows.Next() {