Documentation

Index

Constants

View Source
const (
	ErrorPrefix   = "errors.qilin.store."
	ServicePrefix = "ST"

	HTTPStatusInvalidSession = 474
)

Variables

View Source
var (
	InternalError   = NewError(1001, "internal_error", http.StatusInternalServerError)
	AccessForbidden = NewError(1002, "access_forbidden", http.StatusForbidden)

	MethodNotAllowed        = NewError(1005, "method_not_allowed", http.StatusMethodNotAllowed)
	NotFound                = NewError(1006, "not_found", http.StatusNotFound)
	Unauthorized            = NewError(1007, "unauthorized", http.StatusUnauthorized)
	AuthCodeExchangeFail    = NewError(1008, "auth_code_exchange_failed", http.StatusBadRequest)
	IdTokenNotProvided      = NewError(1009, "id_token_not_provided", http.StatusBadRequest)
	IdTokenVerificationFail = NewError(1010, "id_token_verification_fail", http.StatusBadRequest)
	NotRegistered           = NewError(1011, "not_registered", http.StatusBadRequest)
	SessionSetFailed        = NewError(1012, "failed_to_set_session", http.StatusInternalServerError)
	UnhandledPanic          = NewError(1013, "unhandled_panic", http.StatusInternalServerError)

	InvalidSession   = NewError(1015, "invalid_session", HTTPStatusInvalidSession)
	PasswordMismatch = NewError(1016, "password_mismatch", http.StatusBadRequest)
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    string      `json:"code"`
	Message string      `json:"error"`
	Status  int         `json:"-"`
	Param   string      `json:"param,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

func GQLClientError

func GQLClientError(err string) *APIError

func InvalidParameters

func InvalidParameters(err error) *APIError

func InvalidRequest

func InvalidRequest(err error) *APIError

func NewAPIError

func NewAPIError(code string, message string, status int) *APIError

func NewError

func NewError(code int, message string, status int) *APIError

func RecoveredPanic

func RecoveredPanic(err string) *APIError

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) WithData

func (e *APIError) WithData(data interface{}) *APIError

func (*APIError) WithParam

func (e *APIError) WithParam(param string) *APIError

type ErrorHandler

type ErrorHandler struct {
	// contains filtered or unexported fields
}

func New

func New() *ErrorHandler

func (*ErrorHandler) Handler

func (h *ErrorHandler) Handler(err error, ctx echo.Context)

ErrorHandler represents echo error handler for api

func (*ErrorHandler) Middleware

func (h *ErrorHandler) Middleware() echo.MiddlewareFunc

type Response

type Response struct {
	*APIError
	RequestID string `json:"request_id,omitempty"`
}

Response represents json response for api errors