error

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ALARM_LEVEL_NOTICE   = "notice"
	ALARM_LEVEL_NORMAL   = "normal"
	ALARM_LEVEL_CRITICAL = "critical"
	ALARM_LEVEL_DEADLY   = "deadly"
)

Variables

View Source
var (
	ALARM_SYS_FILE = PublicAlarm{ID: 1001, Type: "OS", Level: ALARM_LEVEL_CRITICAL, Detail: "filesystem not available"}
	ALARM_SYS_CPU  = PublicAlarm{ID: 1002, Type: "OS", Level: ALARM_LEVEL_NORMAL, Detail: "CPU overload"}
	ALARM_SYS_MEM  = PublicAlarm{ID: 1003, Type: "OS", Level: ALARM_LEVEL_CRITICAL, Detail: "memory overload"}
	ALARM_SYS_DISK = PublicAlarm{ID: 1004, Type: "OS", Level: ALARM_LEVEL_CRITICAL, Detail: "disk overload"}

	ALARM_PROC_ETCD = PublicAlarm{ID: 2001, Type: "SYS", Level: ALARM_LEVEL_CRITICAL, Detail: "etcd not available"}
)
View Source
var (
	ERR_EXIST      = errors.New("source exist")
	ERR_NO_EXIST   = errors.New("source not exist")
	ERR_DB         = errors.New("db connect fail")
	ERR_DATA       = errors.New("data invaild")
	ERR_PARM       = errors.New("param invaild")
	ERR_STATUS_EN  = errors.New("status is enable")
	ERR_STATUS_DIS = errors.New("status is disable")
)

系统内部错误码

View Source
var (
	WEB_ERR_OK = PublicRsponse{Code: 0, Message: "success"}

	WEB_ERR_NO_LOGIN    = PublicRsponse{Code: 1001, Message: "no login"}
	WEB_ERR_JSON_CODER  = PublicRsponse{Code: 1002, Message: "json unmarshal fail"}
	WEB_ERR_JSON_UCODER = PublicRsponse{Code: 1003, Message: "json unmarshal fail"}
	WEB_ERR_PARAM       = PublicRsponse{Code: 1004, Message: "input param invalid"}
	WEB_ERR_LOGIN_FAIL  = PublicRsponse{Code: 1005, Message: "login user or password invaild"}
	WEB_ERR_UP_PWD_FAIL = PublicRsponse{Code: 1005, Message: "update user password fail"}

	WEB_ERR_NOT_USERGROUP = PublicRsponse{Code: 2001, Message: "usergroup no found"}
	WEB_ERR_ADD_USERGROUP = PublicRsponse{Code: 2002, Message: "add usergroup fail"}
	WEB_ERR_DEL_USERGROUP = PublicRsponse{Code: 2003, Message: "del usergroup fail"}
	WEB_ERR_UP_USERGROUP  = PublicRsponse{Code: 2004, Message: "update usergroup fail"}

	WEB_ERR_NOT_USER = PublicRsponse{Code: 2101, Message: "user no found"}
	WEB_ERR_ADD_USER = PublicRsponse{Code: 2102, Message: "add user fail"}
	WEB_ERR_DEL_USER = PublicRsponse{Code: 2103, Message: "del user fail"}
	WEB_ERR_UP_USER  = PublicRsponse{Code: 2104, Message: "update user fail"}

	WEB_ERR_ADD_PROXY = PublicRsponse{Code: 3001, Message: "add proxy fail"}
	WEB_ERR_GET_PROXY = PublicRsponse{Code: 3002, Message: "get proxy fail"}
	WEB_ERR_UP_PROXY  = PublicRsponse{Code: 3003, Message: "update proxy fail"}

	WEB_ERR_ADD_RULE = PublicRsponse{Code: 3101, Message: "add rule fail"}
	WEB_ERR_GET_RULE = PublicRsponse{Code: 3102, Message: "get rule fail"}
	WEB_ERR_DEL_RULE = PublicRsponse{Code: 3103, Message: "del rule fail"}
	WEB_ERR_UP_RULE  = PublicRsponse{Code: 3104, Message: "update rule fail"}

	WEB_ERR_ADD_ACCESS = PublicRsponse{Code: 3201, Message: "add access fail"}
	WEB_ERR_GET_ACCESS = PublicRsponse{Code: 3202, Message: "get access fail"}
	WEB_ERR_DEL_ACCESS = PublicRsponse{Code: 3203, Message: "del access fail"}
	WEB_ERR_UP_ACCESS  = PublicRsponse{Code: 3204, Message: "update access fail"}

	WEB_ERR_NOT_ALM = PublicRsponse{Code: 4001, Message: "alm not found"}
)

预定义web错误码

Functions

func WebErr

func WebErr(weberr PublicRsponse, ext ...string) string

func WebOK

func WebOK() string

Types

type PublicAlarm

type PublicAlarm struct {
	ID     int    `json:"id"`
	Type   string `json:"type"`
	Level  string `json:"level"`
	Detail string `json:"detail"`
}

type PublicRsponse

type PublicRsponse struct {
	Code    int    `json:"code"`
	Message string `json:"msg"`
	Extend  string `json:"ext"`
}

请求响应错误信息

func WebErrMake

func WebErrMake(weberr PublicRsponse, ext ...string) PublicRsponse

Jump to

Keyboard shortcuts

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