From ad2585af679a6c5a95056ede9555909588d24ebb Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Sat, 27 Jul 2024 19:04:34 -0400 Subject: [PATCH] backup: show actual error strings in --json mode Previously, an error JSON fragment would look like: {"message_type": "error", "error": {}} This is because encoding/json cannot marshal an error interface. Instead, we now call .Error() to get the string value. --- internal/ui/backup/json.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/ui/backup/json.go b/internal/ui/backup/json.go index 64b5de13b..81bbd1047 100644 --- a/internal/ui/backup/json.go +++ b/internal/ui/backup/json.go @@ -68,7 +68,7 @@ func (b *JSONProgress) Update(total, processed Counter, errors uint, currentFile func (b *JSONProgress) ScannerError(item string, err error) error { b.error(errorUpdate{ MessageType: "error", - Error: err, + Error: err.Error(), During: "scan", Item: item, }) @@ -79,7 +79,7 @@ func (b *JSONProgress) ScannerError(item string, err error) error { func (b *JSONProgress) Error(item string, err error) error { b.error(errorUpdate{ MessageType: "error", - Error: err, + Error: err.Error(), During: "archival", Item: item, }) @@ -208,7 +208,7 @@ type statusUpdate struct { type errorUpdate struct { MessageType string `json:"message_type"` // "error" - Error error `json:"error"` + Error string `json:"error"` During string `json:"during"` Item string `json:"item"` }