errcode

package
v0.0.0-...-cb65031 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errcode redesigned error code

Index

Constants

View Source
const (
	CacheTag     = "TAG"
	CacheArticle = "ARTICLE"
)

Variables

View Source
var (
	Success                   = NewError(100001, "Success")
	InternalServerError       = NewError(100002, "Internal server error")
	InvalidParams             = NewError(100003, "Invalid parameter")
	NotFound                  = NewError(100004, "Not found")
	DatabaseError             = NewError(100101, "Database error")
	UnauthorizedAuthNotExist  = NewError(100201, "Authorized files not exist")
	UnauthorizedTokenError    = NewError(100202, "Token error")
	UnauthorizedTokenTimeout  = NewError(100203, "Token timeout")
	UnauthorizedTokenGenerate = NewError(100204, "Failed to generate token")
	TooManyRequests           = NewError(100301, "Too many requests")
)
View Source
var (
	ErrorGetTagFail     = NewError(200100, "Failed to get tag")
	ErrorGetTagListFail = NewError(200101, "Failed to get tag list")
	ErrorCreateTagFail  = NewError(200102, "Failed to create tag")
	ErrorUpdateTagFail  = NewError(200103, "Failed to update tag")
	ErrorDeleteTagFail  = NewError(200104, "Failed to delete tag")
	ErrorCountTagFail   = NewError(200105, "Failed to count tag")

	ErrorGetArticleFail    = NewError(200201, "Failed to fetch an article")
	ErrorGetArticlesFail   = NewError(200202, "Failed to fetch the articles")
	ErrorCreateArticleFail = NewError(200203, "Failed to create an article")
	ErrorUpdateArticleFail = NewError(200204, "Failed to update an article")
	ErrorDeleteArticleFail = NewError(200205, "Failed to delete an article")

	ErrorUploadFileFail = NewError(200301, "Failed to upload file")
)

Functions

This section is empty.

Types

type Error

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

func NewError

func NewError(code int, msg string) *Error

func (*Error) Code

func (e *Error) Code() int

func (*Error) Details

func (e *Error) Details() []string

func (*Error) Error

func (e *Error) Error() string

func (*Error) Msg

func (e *Error) Msg() string

func (*Error) Msgf

func (e *Error) Msgf(args []any) string

func (*Error) StatusCode

func (e *Error) StatusCode() int

StatusCode converts common error code into http status code

func (*Error) WithDetails

func (e *Error) WithDetails(details ...string) *Error

Jump to

Keyboard shortcuts

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