Skip to content

feat(error): add resource locked error #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scw/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ func unmarshalStandardError(errorType string, body []byte) error {
stdErr = &TransientStateError{RawBody: body}
case "not_found":
stdErr = &ResourceNotFoundError{RawBody: body}
case "locked":
stdErr = &ResourceLockedError{RawBody: body}
case "permissions_denied":
stdErr = &PermissionsDeniedError{RawBody: body}
case "out_of_stock":
Expand Down Expand Up @@ -360,6 +362,22 @@ func (e *ResourceNotFoundError) GetRawBody() json.RawMessage {
return e.RawBody
}

type ResourceLockedError struct {
Resource string `json:"resource"`
ResourceID string `json:"resource_id"`

RawBody json.RawMessage `json:"-"`
}

// IsScwSdkError implements the SdkError interface
func (e *ResourceLockedError) IsScwSdkError() {}
func (e *ResourceLockedError) Error() string {
return fmt.Sprintf("scaleway-sdk-go: resource %s with ID %s is locked", e.Resource, e.ResourceID)
}
func (e *ResourceLockedError) GetRawBody() json.RawMessage {
return e.RawBody
}

type OutOfStockError struct {
Resource string `json:"resource"`

Expand Down