-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy patherror.go
35 lines (30 loc) · 798 Bytes
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package goketo
import "encoding/json"
// ErrorResponse response from list request
type ErrorResponse struct {
RequestID string `json:"requestId"`
Result Result `json:"result"`
Success bool `json:"success"`
}
// Error contains code and count
type Error struct {
Code string `json:"errorCode"`
Count int `json:"count"`
}
// Result contains result stack
type Result struct {
Date string `json:"date"`
Total int `json:"total"`
Errors []Error `json:"errors"`
}
// DailyError returns error codes and their count for the day
func DailyError(req Requester) (errors *ErrorResponse, err error) {
body, err := req.Get("/stats/errors.json")
if err != nil {
return nil, err
}
if err := json.Unmarshal(body, &errors); err != nil {
return nil, err
}
return errors, nil
}