fix(downloader): improve error reporting by returning nil for no error

pull/3834/head
banbxio 2025-04-02 22:28:06 +08:00
parent 02609e6e1e
commit a1a11d482b
1 changed files with 6 additions and 1 deletions

View File

@ -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)