mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
http-backend: http backend lock error return LockError instead of generic error
This commit is contained in:
parent
0d3d95486a
commit
bb1c134b94
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user