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.
This commit is contained in:
Michael Terry 2024-07-27 19:04:34 -04:00
parent f4bdfea1c9
commit ad2585af67

View file

@ -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"`
}