diff --git a/client.go b/client.go index a5f2fe0..d1c5db7 100644 --- a/client.go +++ b/client.go @@ -3,7 +3,6 @@ package tonicpow import ( "encoding/json" "errors" - "fmt" "net/http" "strconv" "time" @@ -156,7 +155,10 @@ func (c *Client) Request(httpMethod string, requestEndpoint string, if err = json.Unmarshal(response.Body, &response.Error); err != nil { return } - err = fmt.Errorf("%s", response.Error.Message) + err = errors.New(response.Error.Message) + if response.StatusCode == 0 { // If a 200 is expected, but you get a 201, this case occurs (improper status code check) + response.StatusCode = http.StatusInternalServerError + } } return diff --git a/client_test.go b/client_test.go index 337816a..1e1e03b 100644 --- a/client_test.go +++ b/client_test.go @@ -208,7 +208,7 @@ func ExampleNewClient() { return } fmt.Printf("loaded client: %s", client.Options().userAgent) - // Output:loaded client: go-tonicpow: v0.7.1 + // Output:loaded client: go-tonicpow: v0.7.2 } // BenchmarkNewClient benchmarks the method NewClient() diff --git a/definitions.go b/definitions.go index 4f67a17..07dd1b9 100644 --- a/definitions.go +++ b/definitions.go @@ -10,7 +10,7 @@ const ( defaultHTTPTimeout = 10 * time.Second // Default timeout for all GET requests in seconds defaultRetryCount int = 2 // Default retry count for HTTP requests defaultUserAgent = "go-tonicpow: " + version // Default user agent - version string = "v0.7.1" // go-tonicpow version + version string = "v0.7.2" // go-tonicpow version // Field key names for various model requests fieldAdvertiserProfileID = "advertiser_profile_id" diff --git a/tonicpow_test.go b/tonicpow_test.go index 32c9051..82546c0 100644 --- a/tonicpow_test.go +++ b/tonicpow_test.go @@ -42,7 +42,7 @@ func TestVersion(t *testing.T) { // See more examples in /examples/ func ExampleVersion() { fmt.Printf("version: %s", Version()) - // Output:version: v0.7.1 + // Output:version: v0.7.2 } // TestUserAgent will test the method UserAgent() @@ -60,7 +60,7 @@ func TestUserAgent(t *testing.T) { // See more examples in /examples/ func ExampleUserAgent() { fmt.Printf("user agent: %s", UserAgent()) - // Output:user agent: go-tonicpow: v0.7.1 + // Output:user agent: go-tonicpow: v0.7.2 } // TestGetFeedType will test the method GetFeedType()