errors

package
v0.0.0-...-4c53254 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2015 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCodeOK = 0

	ErrCodeBadRequest          = 10000 // 输入参数不正确, 包括 url 参数和 http-body-json 参数
	ErrCodeInternalServerError = 10001 // 内部服务器出错
	ErrCodeNotSupported        = 10002 // 不支持

	ErrCodeTokenMissing        = 20000 // token 缺失
	ErrCodeTokenEncodeFailed   = 20001 // token 编码出错
	ErrCodeTokenDecodeFailed   = 20002 // token 解码出错
	ErrCodeTokenAccessExpired  = 20003 // token access 过期
	ErrCodeTokenRefreshExpired = 20004 // token refresh 过期
	ErrCodeTokenShouldNotGuest = 20005 // token 不能是 guest 认证的
	ErrCodeTokenInvalid        = 20006 // token 失效, 应该重新认证

	ErrCodeAuthFailed         = 20010 // 认证失败
	ErrCodeOAuthStateMismatch = 20011 // oauth state 不匹配
)

Variables

View Source
var (
	ErrOK = &Error{
		ErrCode: ErrCodeOK,
		ErrMsg:  "success",
	}

	ErrBadRequest = &Error{
		ErrCode: ErrCodeBadRequest,
		ErrMsg:  "bad request",
	}
	ErrInternalServerError = &Error{
		ErrCode: ErrCodeInternalServerError,
		ErrMsg:  "internal server error",
	}
	ErrNotSupported = &Error{
		ErrCode: ErrCodeNotSupported,
		ErrMsg:  "not supported",
	}

	ErrTokenMissing = &Error{
		ErrCode: ErrCodeTokenMissing,
		ErrMsg:  "token missing",
	}
	ErrTokenEncodeFailed = &Error{
		ErrCode: ErrCodeTokenEncodeFailed,
		ErrMsg:  "token encoding failed",
	}
	ErrTokenDecodeFailed = &Error{
		ErrCode: ErrCodeTokenDecodeFailed,
		ErrMsg:  "token decoding failed",
	}
	ErrTokenAccessExpired = &Error{
		ErrCode: ErrCodeTokenAccessExpired,
		ErrMsg:  "token access expired",
	}
	ErrTokenRefreshExpired = &Error{
		ErrCode: ErrCodeTokenRefreshExpired,
		ErrMsg:  "token refresh expired",
	}
	ErrTokenShouldNotGuest = &Error{
		ErrCode: ErrCodeTokenShouldNotGuest,
		ErrMsg:  "token should not be authenticated via guest",
	}
	ErrTokenInvalid = &Error{
		ErrCode: ErrCodeTokenInvalid,
		ErrMsg:  "token is invalid",
	}

	ErrAuthFailed = &Error{
		ErrCode: ErrCodeAuthFailed,
		ErrMsg:  "authentication failed",
	}
	ErrOAuthStateMismatch = &Error{
		ErrCode: ErrCodeOAuthStateMismatch,
		ErrMsg:  "the oauth state mismatch",
	}
)
View Source
var ErrNotFound = errors.New("item not found")

Functions

This section is empty.

Types

type Error

type Error struct {
	ErrCode int    `json:"err_code"`
	ErrMsg  string `json:"err_msg"`
}

func NewError

func NewError(ErrCode int, ErrMsg string) *Error

func (*Error) Error

func (e *Error) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL