-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy patherrors.go
More file actions
29 lines (23 loc) · 696 Bytes
/
errors.go
File metadata and controls
29 lines (23 loc) · 696 Bytes
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
package goplaces
import "fmt"
// ErrMissingAPIKey indicates a missing API key.
var ErrMissingAPIKey = fmt.Errorf("goplaces: missing api key")
// ValidationError describes an invalid request payload.
type ValidationError struct {
Field string
Message string
}
func (e ValidationError) Error() string {
return fmt.Sprintf("goplaces: invalid %s: %s", e.Field, e.Message)
}
// APIError represents an HTTP error from the Places API.
type APIError struct {
StatusCode int
Body string
}
func (e *APIError) Error() string {
if e.Body == "" {
return fmt.Sprintf("goplaces: api error (%d)", e.StatusCode)
}
return fmt.Sprintf("goplaces: api error (%d): %s", e.StatusCode, e.Body)
}