-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy patherror.go
More file actions
35 lines (29 loc) · 799 Bytes
/
error.go
File metadata and controls
35 lines (29 loc) · 799 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
30
31
32
33
34
35
package detectlanguage
import "fmt"
// APIError is an error returned from the API
type APIError struct {
// Status is the HTTP text status of the response.
Status string
// StatusCode is the HTTP numerical status code of the response.
StatusCode int
// Code is an error code returned by the API.
Code int `json:"code"`
// Message is a human-readable error code returned by the API.
Message string `json:"message"`
}
func (e *APIError) Error() string {
if e.Message != "" {
return e.Message
}
return fmt.Sprintf("%d %s", e.StatusCode, e.Status)
}
type apiErrorResponse struct {
Error *APIError `json:"error,omitempty"`
}
// DetectionError is retuned when detection fails
type DetectionError struct {
Message string
}
func (e *DetectionError) Error() string {
return e.Message
}