This ensures that we can catch certain types of errors from providers and handle accordingly in the core. There is still more to do here to improve that but this resolves an immediate need to know why a Delete failed. vic provider was not updated since I could not figure out where to get this information.
27 lines
381 B
Go
27 lines
381 B
Go
package alicloud
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/aliyun/alibaba-cloud-sdk-go/sdk/errors"
|
|
"github.com/cpuguy83/strongerrors"
|
|
)
|
|
|
|
func wrapError(err error) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
se, ok := err.(*errors.ServerError)
|
|
if !ok {
|
|
return err
|
|
}
|
|
|
|
switch se.HttpStatus() {
|
|
case http.StatusNotFound:
|
|
return strongerrors.NotFound(err)
|
|
default:
|
|
return err
|
|
}
|
|
}
|