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
385 B
Go
27 lines
385 B
Go
package azure
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/cpuguy83/strongerrors"
|
|
"github.com/virtual-kubelet/virtual-kubelet/providers/azure/client/api"
|
|
)
|
|
|
|
func wrapError(err error) error {
|
|
if err == nil {
|
|
return nil
|
|
}
|
|
|
|
e, ok := err.(*api.Error)
|
|
if !ok {
|
|
return err
|
|
}
|
|
|
|
switch e.StatusCode {
|
|
case http.StatusNotFound:
|
|
return strongerrors.NotFound(err)
|
|
default:
|
|
return err
|
|
}
|
|
}
|