Skip to content
Merged
Show file tree
Hide file tree
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
12 changes: 12 additions & 0 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ func IsNotSupported(err error) bool {
return hcs.IsNotSupported(getInnerError(err))
}

// IsOperationInvalidState returns true when err is caused by
// `ErrVmcomputeOperationInvalidState`.
func IsOperationInvalidState(err error) bool {
return hcs.IsOperationInvalidState(getInnerError(err))
}

// IsAccessIsDenied returns true when err is caused by
// `ErrVmcomputeOperationAccessIsDenied`.
func IsAccessIsDenied(err error) bool {
return hcs.IsAccessIsDenied(getInnerError(err))
}

func getInnerError(err error) error {
switch pe := err.(type) {
case nil:
Expand Down
7 changes: 7 additions & 0 deletions internal/hcs/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ func IsOperationInvalidState(err error) bool {
return err == ErrVmcomputeOperationInvalidState
}

// IsAccessIsDenied returns true when err is caused by
// `ErrVmcomputeOperationAccessIsDenied`.
func IsAccessIsDenied(err error) bool {
err = getInnerError(err)
return err == ErrVmcomputeOperationAccessIsDenied
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could be

return ErrVmComputeOperationAccessIsDenied == getInnerError(err)

I know this is just following the same for the others however

}

func getInnerError(err error) error {
switch pe := err.(type) {
case nil:
Expand Down