fix(downloader): improve error reporting by returning nil for no error
This commit is contained in:
parent
02609e6e1e
commit
a1a11d482b
@ -108,7 +108,12 @@ func downloadStatusHandler(downloaderCache *cache.Cache) handleFunc {
|
|||||||
"url": taskCache.URL,
|
"url": taskCache.URL,
|
||||||
"taskID": taskCache.TaskID.String(),
|
"taskID": taskCache.TaskID.String(),
|
||||||
"status": taskCache.status,
|
"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")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
err := json.NewEncoder(w).Encode(&responseBody)
|
err := json.NewEncoder(w).Encode(&responseBody)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user