From 1e6897238b57b70be623231d839558e682e30e90 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Thu, 28 Jan 2021 12:05:20 -0800 Subject: [PATCH] Expose internal errors via hscshim Signed-off-by: James Sturtevant --- errors.go | 12 ++++++++++++ internal/hcs/errors.go | 7 +++++++ 2 files changed, 19 insertions(+) diff --git a/errors.go b/errors.go index 63efa23c7a..061727c679 100644 --- a/errors.go +++ b/errors.go @@ -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: diff --git a/internal/hcs/errors.go b/internal/hcs/errors.go index 9a4705a494..bca824b8e1 100644 --- a/internal/hcs/errors.go +++ b/internal/hcs/errors.go @@ -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 +} + func getInnerError(err error) error { switch pe := err.(type) { case nil: