Skip to content

Commit

Permalink
Merge pull request #13 from Ensighten/fix_return_error_on_404
Browse files Browse the repository at this point in the history
Pass error on 404 instead of nil
  • Loading branch information
bobtfish authored Sep 3, 2016
2 parents 1d343da + 8393fc2 commit 7c167e5
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions nsone.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,7 @@ func (c APIClient) GetZones() ([]Zone, error) {
// GetZone takes a zone and returns a single active zone and its basic configuration details
func (c APIClient) GetZone(zone string) (*Zone, error) {
z := NewZone(zone)
status, err := c.doHTTPUnmarshal("GET", fmt.Sprintf("https://api.nsone.net/v1/zones/%s", z.Zone), nil, z)
if status == 404 {
z.Id = ""
z.Zone = ""
return z, nil
}
_, err := c.doHTTPUnmarshal("GET", fmt.Sprintf("https://api.nsone.net/v1/zones/%s", z.Zone), nil, z)
return z, err
}

Expand Down Expand Up @@ -274,12 +269,7 @@ func (c APIClient) GetMonitoringJobs() (MonitoringJobs, error) {
// GetMonitoringJob takes an ID and returns details for a specific monitoring job
func (c APIClient) GetMonitoringJob(id string) (MonitoringJob, error) {
var mj MonitoringJob
status, err := c.doHTTPUnmarshal("GET", fmt.Sprintf("https://api.nsone.net/v1/monitoring/jobs/%s", id), nil, &mj)
if status == 404 {
mj.Id = ""
mj.Name = ""
return mj, nil
}
_, err := c.doHTTPUnmarshal("GET", fmt.Sprintf("https://api.nsone.net/v1/monitoring/jobs/%s", id), nil, &mj)
return mj, err
}

Expand Down

0 comments on commit 7c167e5

Please sign in to comment.