Newer
Older
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package apierrors
// APIError is the base API error type.
type APIError struct {
Success bool `json:"success"`
StatusCode int `json:"errorcode"`
Description string `json:"description"`
PolrStyle bool `json:"-"`
}
// Generic errors (Pomf style)
var (
// BadToken is a 401 unauthorized error.
BadToken = APIError{false, 401, "bad token", false}
// Unauthorized is a 401 unauthorized error.
Unauthorized = APIError{false, 401, "unauthorized", false}
// InvalidJSONPayload is a 400 bad request error.
InvalidJSONPayload = APIError{false, 400, "invalid JSON payload", false}
// EmailOrUsernameNotSupplied is a 400 bad request error.
EmailOrUsernameNotSupplied = APIError{false, 400, "email or username not provided", false}
// InvalidEmailOrUsername is a 400 bad request error.
InvalidEmailOrUsername = APIError{false, 400, "invalid email or username", false}
// UserExists is a 409 conflict error.
UserExists = APIError{false, 409, "user with that email or username already exists", false}
)
// Pomf errors
var (
// ContentLengthRequired is a 411 length required error.
ContentLengthRequired = APIError{false, 411, "Content-Length header required", false}
// InvalidContentLength is a 400 bad request error.
InvalidContentLength = APIError{false, 400, "invalid Content-Length header, should be an integer", false}
// BodyTooLarge is a 413 payload too large error.
BodyTooLarge = APIError{false, 413, "request body too large, DO NOT reattempt upload", false}
// NoFilesInRequest is a 400 bad request error.
NoFilesInRequest = APIError{false, 400, "no files[] present in multipart/form-data body", false}
// TooManyFilesInRequest a 400 bad request error.
TooManyFilesInRequest = APIError{false, 400, "too many files[] present in multipart/form-data body", false}
// InternalServerError is a 500 internal server error.
InternalServerError = APIError{false, 500, "internal server error", false}
)
// Polr errors
var (
// UnauthorizedPolr is a 401 unauthorized error.
UnauthorizedPolr = APIError{false, 400, "unauthorized", true}
// InvalidPolrAction is a 400 bad request error.
InvalidPolrAction = APIError{false, 400, `invalid action, must be "shorten"`, true}
// InvalidPolrURL is a 400 bad request error.
InvalidPolrURL = APIError{false, 400, "invalid URL", true}
// InternalServerErrorPolr is a 500 internal server error.
InternalServerErrorPolr = APIError{false, 500, "internal server error", true}
)