bcode

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: LGPL-3.0 Imports: 5 Imported by: 0

README

API Business Code Library

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// 10000~19999 for global configs.
	// ErrGenHTTPDomain failed to generate http domain
	ErrGenHTTPDomain = newCodeWithMsg(10001, "failed to generate http domain")
	ErrInvalidNodes  = newCodeWithMsg(10002, "invalid nodes")
	// ErrClusterNotFound rainbondcluster not found
	ErrClusterNotFound        = newCodeWithStatus(404, 10003, "rainbondcluster not found")
	ErrClusterPreCheckNotPass = newCodeWithStatus(400, 10004, "cluster precheck not pass")

	// 20000~29999 for rainbond package
	// ErrCreateRainbondPackage failed to create rainbond package
	ErrCreateRainbondPackage = newCodeWithMsg(20001, "failed to create rainbond package")

	// 30000~39999 for rainbond volume
	// ErrCreateRainbondVolume failed to create rainbond volume
	ErrCreateRainbondVolume = newCodeWithMsg(30001, "failed to create rainbond volume")

	// 40000~49999 for rainbond component
	// ErrCreateRainbondVolume failed to create rainbond component
	ErrCreateRbdComponent   = newCodeWithMsg(40001, "failed to create rainbond component")
	ErrRbdComponentNotFound = newCodeWithStatus(404, 40002, "rbdcomponent not found")
)

business code for pkg/openapi/cluster

View Source
var (
	// OK means everything si good.
	OK = newCodeWithMsg(200, "ok")

	// BadRequest means the request could not be understood by the server due to malformed syntax.
	// The client SHOULD NOT repeat the request without modifications.
	BadRequest = newCodeWithMsg(400, "bad request")
	// NotFound means the server has not found anything matching the request.
	NotFound = newCode(404)
	// ServerErr means  the server encountered an unexpected condition which prevented it from fulfilling the request.
	ServerErr = newCode(500)
)
View Source
var (
	ErrInvalidVersion         = newCodeWithStatus(400, 1000, "invalid version")
	ErrCurrentVersionNotFound = newCodeWithStatus(404, 1001, "current version not found")
	ErrInvalidCurrentVersion  = newCodeWithStatus(400, 1002, "invalid current version")
	ErrLowerVersion           = newCodeWithStatus(400, 1003, "lower version, do not support downgrade")
	ErrVersionNotFound        = newCodeWithStatus(404, 1004, "version not found")
	ErrReadRbdComponent       = newCodeWithStatus(404, 1005, "can't read rbdcomponents")
)

business code for pkg/openapi/cluster

Functions

This section is empty.

Types

type Code

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

Code represents a business code.

func (Code) Code

func (c Code) Code() int

Code returns a business code

func (Code) Error

func (c Code) Error() string

func (Code) Msg

func (c Code) Msg() string

Msg returns a message

func (Code) Status

func (c Code) Status() int

Status returns a http status code.

type Coder

type Coder interface {
	// http status code
	Status() int
	// business code
	Code() int
	Error() string
	Msg() string
}

Coder has ability to get code, msg or detail from error.

func Err2Coder

func Err2Coder(err error) Coder

Err2Coder converts the given err to Coder.

func Str2Coder

func Str2Coder(str string) Coder

Str2Coder converts the given str to Coder.

Jump to

Keyboard shortcuts

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