2015-02-10 04:27:39 +01:00
|
|
|
package openstack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2016-09-04 04:51:22 +02:00
|
|
|
"github.com/gophercloud/gophercloud"
|
2015-02-10 04:27:39 +01:00
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
)
|
|
|
|
|
|
|
|
// CheckDeleted checks the error to see if it's a 404 (Not Found) and, if so,
|
|
|
|
// sets the resource ID to the empty string instead of throwing an error.
|
2015-02-13 01:25:45 +01:00
|
|
|
func CheckDeleted(d *schema.ResourceData, err error, msg string) error {
|
2016-09-04 06:57:25 +02:00
|
|
|
if _, ok := err.(gophercloud.ErrDefault404); ok {
|
2015-02-10 04:27:39 +01:00
|
|
|
d.SetId("")
|
|
|
|
return nil
|
|
|
|
}
|
2016-09-04 06:57:25 +02:00
|
|
|
|
2015-02-13 01:25:45 +01:00
|
|
|
return fmt.Errorf("%s: %s", msg, err)
|
2015-02-10 04:27:39 +01:00
|
|
|
}
|