errcode

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package errcode defines the base errors with corresponding error code.

errcode only allowed the following http status: StatusOK = 200 // RFC 7231, 6.3.1 StatusBadRequest = 400 // RFC 7231, 6.5.1 StatusUnauthorized = 401 // RFC 7235, 3.1 StatusForbidden = 403 // RFC 7231, 6.5.3 StatusNotFound = 404 // RFC 7231, 6.5.4 StatusInternalServerError = 500 // RFC 7231, 6.6.1

Index

Constants

View Source
const (
	// ErrSuccess - 200: OK.
	ErrSuccess int = iota + 100001

	// ErrUnknown - 500: Internal server error.
	ErrUnknown

	// ErrBadParams - 400: Bad request parameters.
	ErrBadParams

	// ErrPageNotFound - 404: Not found.
	ErrNotFound
)

Common: basic errors (1000xx).

View Source
const (
	// ErrPasswordInvalid - 401: Password invalid.
	ErrPasswordInvalid int = iota + 100101

	// ErrHeaderInvalid - 401: Authorization header invalid.
	ErrHeaderInvalid

	// ErrSignatureInvalid - 401: Signature invalid.
	ErrSignatureInvalid

	// ErrTokenInvalid - 401: Token invalid.
	ErrTokenInvalid

	// ErrTokenExpired - 401: Token expired.
	ErrTokenExpired

	// PermissionDenied - 403: Permission denied.
	ErrPermissionDenied
)

common: authorization / authentication errors (1001xx).

View Source
const (
	// ErrDatabase - 500: Database error.
	ErrDatabase int = iota + 100201
)

common: database errors (1002xx).

Variables

View Source
var ValidHTTPStatus = []int{200, 400, 401, 403, 404, 500}

Functions

This section is empty.

Types

type ErrCode

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

ErrCode implements `github.com/marmotedu/errors` Coder interface.

func (ErrCode) Code

func (coder ErrCode) Code() int

Code returns the integer error code.

func (ErrCode) HTTPStatus

func (coder ErrCode) HTTPStatus() int

HTTPStatus returns the associated HTTP status code.

func (ErrCode) Reference

func (coder ErrCode) Reference() string

Reference returns the reference document.

func (ErrCode) String

func (coder ErrCode) String() string

String implements stringer.

Jump to

Keyboard shortcuts

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