Skip to content

Commit ed75df8

Browse files
author
Scott McAllister
committed
Merge branch 'event_return_http_code' of https://github.com/yomashExpel/go-pagerduty into prs-04feb2020
2 parents 1bd6243 + cb8001f commit ed75df8

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

event.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type EventResponse struct {
2626
Status string `json:"status"`
2727
Message string `json:"message"`
2828
IncidentKey string `json:"incident_key"`
29+
HttpStatus int
2930
}
3031

3132
// CreateEvent sends PagerDuty an event to trigger, acknowledge, or resolve a
@@ -48,11 +49,11 @@ func CreateEventWithHTTPClient(e Event, client HTTPClient) (*EventResponse, erro
4849
req.Header.Set("Content-Type", "application/json")
4950
resp, err := client.Do(req)
5051
if err != nil {
51-
return nil, err
52+
return &EventResponse{HttpStatus: resp.StatusCode}, err
5253
}
5354
defer resp.Body.Close()
5455
if resp.StatusCode != http.StatusOK {
55-
return nil, fmt.Errorf("HTTP Status Code: %d", resp.StatusCode)
56+
return &EventResponse{HttpStatus: resp.StatusCode}, fmt.Errorf("HTTP Status Code: %d", resp.StatusCode)
5657
}
5758
var eventResponse EventResponse
5859
if err := json.NewDecoder(resp.Body).Decode(&eventResponse); err != nil {

0 commit comments

Comments
 (0)