Skip to content

Commit 0eec5e5

Browse files
committed
improvement to error handling
1 parent 7afe9ed commit 0eec5e5

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

aws/aws.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -957,7 +957,10 @@ func (s *awsOps) AreVolumesReadyToExpand(volumeIDs []*string) (bool, error) {
957957
if isErrorModificationNotFound(err) {
958958
return true, nil
959959
}
960-
return false, fmt.Errorf("unable to get modification states for aws volumes: %v", err)
960+
return false, &cloudops.ErrCloudProviderRequestFailure{
961+
Request: "DescribeVolumesModifications",
962+
Message: err.Error(),
963+
}
961964
}
962965
states := describeOutput.VolumesModifications
963966

errors.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,3 +112,15 @@ type ErrCurrentCapacityHigherThanDesired struct {
112112
func (e *ErrCurrentCapacityHigherThanDesired) Error() string {
113113
return fmt.Sprintf("current capacity (%d) is higher than desired capacity: %d", e.Current, e.Desired)
114114
}
115+
116+
// ErrCloudProviderRequestFailure is returned when an unknown API request failure occurred.
117+
type ErrCloudProviderRequestFailure struct {
118+
// Request is the API function name
119+
Request string
120+
// Message is the error message returned by the cloud provider
121+
Message string
122+
}
123+
124+
func (e *ErrCloudProviderRequestFailure) Error() string {
125+
return fmt.Sprintf("Request %s returns %s", e.Request, e.Message)
126+
}

0 commit comments

Comments
 (0)