-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.go
27 lines (24 loc) · 1.16 KB
/
common.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
package ecode
import "net/http"
const (
// UnknownCode is unknown code for error info.
UnknownCode = http.StatusInternalServerError
// UnknownReason is unknown reason for error info.
UnknownReason = ""
// ClientClosed is non-standard http status code,
// which defined by nginx.
// https://httpstatus.in/499/
ClientClosed = 499
)
var (
// base error
Success = New(http.StatusOK, "SUCCESS", "success")
RequestErr = New(http.StatusBadRequest, "PARAM_ERROR", "request param error")
UnauthorizedErr = New(http.StatusUnauthorized, "SIGN_ERROR", "sign error")
ForbiddenErr = New(http.StatusForbidden, "NO_AUTH", "no auth")
NotFoundErr = New(http.StatusNotFound, "RESOURCE_NOT_FOUND", "resource not found")
TooManyRequestErr = New(http.StatusTooManyRequests, "RATELIMIT_EXCEEDED", "ratelimit exceeded")
ServerErr = New(http.StatusInternalServerError, "SERVER_ERROR", "server error")
BadGatewayErr = New(http.StatusBadGateway, "SERVICE_UNAVAILABLE", "service offline, unavailable")
ServiceUnavailableErr = New(http.StatusServiceUnavailable, "SERVICE_UNAVAILABLE", "service protected, unavailable")
)