From a1a11d482bfcc38bc250c955f23ad190c6db2bec Mon Sep 17 00:00:00 2001 From: banbxio Date: Wed, 2 Apr 2025 22:28:06 +0800 Subject: [PATCH] fix(downloader): improve error reporting by returning nil for no error --- http/downloader.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/http/downloader.go b/http/downloader.go index b40c9cfb..5ef0e789 100644 --- a/http/downloader.go +++ b/http/downloader.go @@ -108,7 +108,12 @@ func downloadStatusHandler(downloaderCache *cache.Cache) handleFunc { "url": taskCache.URL, "taskID": taskCache.TaskID.String(), "status": taskCache.status, - "error": fmt.Sprint(taskCache.err), + "error": func() interface{} { + if taskCache.err == nil { + return nil + } + return taskCache.err.Error() + }(), } w.Header().Set("Content-Type", "application/json") err := json.NewEncoder(w).Encode(&responseBody)