json: switch backup and restore errors from string to struct types

This keeps backwards compatibility with the previous empty structs.
And maybe we'd want to put other fields into the inner struct later,
rather than the outer message.
This commit is contained in:
Michael Terry
2024-08-03 15:29:10 -04:00
parent a376323331
commit 88f59fc2d6
5 changed files with 36 additions and 15 deletions

View File

@@ -48,7 +48,7 @@ func (t *jsonPrinter) Update(p State, duration time.Duration) {
func (t *jsonPrinter) Error(item string, err error) error {
t.error(errorUpdate{
MessageType: "error",
Error: err.Error(),
Error: errorObject{err.Error()},
During: "restore",
Item: item,
})
@@ -113,11 +113,15 @@ type statusUpdate struct {
BytesSkipped uint64 `json:"bytes_skipped,omitempty"`
}
type errorObject struct {
Message string `json:"message"`
}
type errorUpdate struct {
MessageType string `json:"message_type"` // "error"
Error string `json:"error"`
During string `json:"during"`
Item string `json:"item"`
MessageType string `json:"message_type"` // "error"
Error errorObject `json:"error"`
During string `json:"during"`
Item string `json:"item"`
}
type verboseUpdate struct {