diff --git a/internal/backend/remote-state/http/client.go b/internal/backend/remote-state/http/client.go index 0aed96886d..71668c0a2d 100644 --- a/internal/backend/remote-state/http/client.go +++ b/internal/backend/remote-state/http/client.go @@ -100,14 +100,23 @@ func (c *httpClient) Lock(info *statemgr.LockInfo) (string, error) { defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { - return "", fmt.Errorf("HTTP remote state already locked, failed to read body") + return "", &statemgr.LockError{ + Info: info, + Err: fmt.Errorf("HTTP remote state already locked, failed to read body"), + } } existing := statemgr.LockInfo{} err = json.Unmarshal(body, &existing) if err != nil { - return "", fmt.Errorf("HTTP remote state already locked, failed to unmarshal body") + return "", &statemgr.LockError{ + Info: info, + Err: fmt.Errorf("HTTP remote state already locked, failed to unmarshal body"), + } + } + return "", &statemgr.LockError{ + Info: info, + Err: fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID), } - return "", fmt.Errorf("HTTP remote state already locked: ID=%s", existing.ID) default: return "", fmt.Errorf("Unexpected HTTP response code %d", resp.StatusCode) }