2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 03:18:55 +00:00

backend/rest: check HTTP error response for List

Before this change restic would attempt to JSON decode the error
message resulting in confusing `Decode: invalid character 'B' looking
for beginning of value` messages.  Afterwards it will return `List
failed, server response: 400 Bad Request (400)`
This commit is contained in:
Nick Craig-Wood 2018-03-08 10:22:43 +00:00
parent de37b68baa
commit 04c4033695

View File

@ -335,7 +335,11 @@ func (b *restBackend) List(ctx context.Context, t restic.FileType, fn func(resti
b.sem.ReleaseToken()
if err != nil {
return errors.Wrap(err, "Get")
return errors.Wrap(err, "List")
}
if resp.StatusCode != 200 {
return errors.Errorf("List failed, server response: %v (%v)", resp.Status, resp.StatusCode)
}
if resp.Header.Get("Content-Type") == contentTypeV2 {