Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Handle strining of ints and json errors #110

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uptimerobot/api/alert_contact.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (client UptimeRobotApiClient) GetAlertContacts() (acs []AlertContact, err e
}

if float64(len(acs)) != total {
err = errors.New("Hitting pagination limit of: " + string(page_limit))
err = fmt.Errorf("Hitting pagination limit of: %d", page_limit)
}

return
Expand Down
11 changes: 7 additions & 4 deletions uptimerobot/api/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package uptimerobotapi

import (
"encoding/json"
"errors"
"fmt"
"net/url"
"sort"
Expand Down Expand Up @@ -96,13 +95,17 @@ func (client UptimeRobotApiClient) GetMonitor(id int) (m Monitor, err error) {

monitors, ok := body["monitors"].([]interface{})
if !ok {
j, _ := json.Marshal(body)
err = errors.New("Unknown response from the server: " + string(j))
j, jsonErr := json.Marshal(body)
if err != nil {
err = fmt.Errorf("Unable to parse the JSON response from the server: %s. Body: %s", jsonErr, body)
return
}
err = fmt.Errorf("Missing 'monitors' in JSON response from the server: %v", j)
return
}

if len(monitors) < 1 {
err = errors.New("Monitor not found: " + string(id))
err = fmt.Errorf("Monitor not found: %d", id)
return
}

Expand Down