11package improvmx
22
33import (
4+ "fmt"
45 "log"
56 "time"
67
@@ -47,6 +48,11 @@ func resourceDomainCreate(d *schema.ResourceData, meta interface{}) error {
4748 time .Sleep (10 * time .Second )
4849 }
4950
51+ if resp .Code == 404 {
52+ log .Printf ("[DEBUG] Couldn't find the resource in ImprovMX. Aborting" )
53+ return fmt .Errorf ("HTTP response code %d, error text: %s" , resp .Code , resp .Errors .Domain )
54+ }
55+
5056 if resp .Success {
5157 return resourceDomainRead (d , meta )
5258 }
@@ -68,6 +74,11 @@ func resourceDomainRead(d *schema.ResourceData, meta interface{}) error {
6874 time .Sleep (10 * time .Second )
6975 }
7076
77+ if resp .Code == 404 {
78+ log .Printf ("[DEBUG] Couldn't find the resource in ImprovMX. Aborting" )
79+ return fmt .Errorf ("HTTP response code %d, error text: %s" , resp .Code , resp .Errors .Domain )
80+ }
81+
7182 if resp .Success {
7283 d .SetId (resp .Domain .Domain )
7384 d .Set ("domain" , resp .Domain .Domain )
@@ -92,6 +103,11 @@ func resourceDomainUpdate(d *schema.ResourceData, meta interface{}) error {
92103 time .Sleep (10 * time .Second )
93104 }
94105
106+ if resp .Code == 404 {
107+ log .Printf ("[DEBUG] Couldn't find the resource in ImprovMX. Aborting" )
108+ return fmt .Errorf ("HTTP response code %d, error text: %s" , resp .Code , resp .Errors .Domain )
109+ }
110+
95111 if resp .Success {
96112 return resourceDomainRead (d , meta )
97113 }
0 commit comments