app/vmbackup/snapshot: log url and response body on failed JSON response parsing

Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/929
This commit is contained in:
Aliaksandr Valialkin 2020-11-29 12:15:31 +02:00
parent 0463cb5550
commit b35b3dc043

View File

@ -39,7 +39,7 @@ func Create(createSnapshotURL string) (string, error) {
snap := snapshot{}
err = json.Unmarshal(body, &snap)
if err != nil {
return "", err
return "", fmt.Errorf("cannot parse JSON response from %q: %w; response body: %q", createSnapshotURL, err, body)
}
if snap.Status == "ok" {
@ -77,7 +77,7 @@ func Delete(deleteSnapshotURL string, snapshotName string) error {
snap := snapshot{}
err = json.Unmarshal(body, &snap)
if err != nil {
return err
return fmt.Errorf("cannot parse JSON response from %q: %w; response body: %q", deleteSnapshotURL, err, body)
}
if snap.Status == "ok" {