errors

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 2 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// json
	// -32768 to -32000 is the reserved predefined error code
	// the server received an invalid JSON. The error is sent to the server trying to parse the JSON text
	ErrParseError = JsonError{Code: -32700, Message: "Parse error"}
	// the sent JSON is not a valid request object
	ErrInvalidRequest = JsonError{Code: -32600, Message: "Invalid request"}
	// the method does not exist or is invalid
	ErrMethodNotFound = JsonError{Code: -32601, Message: "Method not found"}
	ErrInvalidParams  = JsonError{Code: -32602, Message: "Invalid params"} // invalid method parameter
	ErrInternalError  = JsonError{Code: -32603, Message: "Internal error"} // json-rpc internal error.

	// txPool
	// the object is nil
	ErrStructEmpty = JsonError{Code: -31100, Message: "Struct is nil"}
	// tx-id already exists
	ErrTxIdExist = JsonError{Code: -31105, Message: "TxId exist"}
	// tx-id already exists in DB
	ErrTxIdExistDB = JsonError{Code: -31106, Message: "TxId exist in DB"}
	// tx-timestamp out of range
	ErrTxTimeout = JsonError{Code: -31108, Message: "TxTimestamp error"}
	// transaction pool is full
	ErrTxPoolLimit = JsonError{Code: -31110, Message: "TxPool is full"}
	// tx-source is error
	ErrTxSource = JsonError{Code: -31112, Message: "TxSource is err"}
	// The tx had been on the block chain
	ErrTxHadOnTheChain = JsonError{Code: -31113, Message: "The tx had been on the block chain"}
	// The txPool service has stopped
	ErrTxPoolHasStopped = JsonError{Code: -31114, Message: "The tx pool has stopped"}
	// The txPool service has started
	ErrTxPoolHasStarted = JsonError{Code: -31115, Message: "The tx pool has started"}
	// The txPool service stop failed
	ErrTxPoolStopFailed = JsonError{Code: -31116, Message: "The tx pool stop failed"}
	// The txPool service start failed
	ErrTxPoolStartFailed = JsonError{Code: -31117, Message: "The tx pool start failed"}

	// core
	// block had been committed
	ErrBlockHadBeenCommited = JsonError{Code: -31200, Message: "Block had been committed err"}
	// block concurrent verify error
	ErrConcurrentVerify = JsonError{Code: -31201, Message: "Block concurrent verify err"}
	// block had been verified
	ErrRepeatedVerify = JsonError{Code: -31202, Message: "Block had been verified err"}

	// sync
	// The sync service has been started
	ErrSyncServiceHasStarted = JsonError{Code: -33000, Message: "The sync service has been started"}
	// The sync service has been stoped
	ErrSyncServiceHasStoped = JsonError{Code: -33001, Message: "The sync service has been stoped"}

	// store
	// The store service has been started
	ErrStoreServiceNeedRestarted = JsonError{Code: -34000, Message: "The store service need restart"}
)
View Source
var ErrCodeName = map[ErrCode][]string{
	ERR_CODE_OK:                                      {"OK", "OK"},
	ERR_CODE_SYSTEM_CONTRACT_PB_UNMARSHAL:            {"pb unmarshal failed", "系统合约PB结构解析失败"},
	ERR_CODE_SYSTEM_CONTRACT_UNKNOWN_TX_ROUTE_MAP:    {"unknown tx type route", "未知交易类型路由"},
	ERR_CODE_SYSTEM_CONTRACT_UNSUPPORT_CONTRACT_NAME: {"unsupport contract name", "不支持的合约名"},
	ERR_CODE_SYSTEM_CONTRACT_UNSUPPORT_METHOD_NAME:   {"unsupport method name", "不支持的方法名"},
	ERR_CODE_SYSTEM_CONTRACT_QUERY_FAILED:            {"call query contract failed", "调用查询系统合约失败"},
	ERR_CODE_SYSTEM_CONTRACT_CONTRACT_FAILED: {
		"call contract contract failed",
		"调用交易系统合约失败",
	},
	ERR_CODE_CHECK_PAYLOAD_PARAM_SUBSCRIBE_BLOCK: {
		"check subscribe block payload failed",
		"校验订阅区块Payload数据失败",
	},
	ERR_CODE_CHECK_PAYLOAD_PARAM_SUBSCRIBE_TX: {
		"check subscribe tx payload params failed",
		"校验订阅交易Payload数据失败",
	},
	ERR_CODE_CHECK_PAYLOAD_PARAM_SUBSCRIBE_CONTRACT_EVENT: {
		"check subscribe contract event payload params failed",
		"校验订阅合约事件Payload数据失败",
	},
	ERR_CODE_CHECK_PAYLOAD_PARAM_ARCHIVE_BLOCK: {
		"check archive block payload params failed",
		"校验数据归档数据失败",
	},
	ERR_CODE_TX_ADD_FAILED:    {"tx add failed", "添加交易失败"},
	ERR_CODE_TX_VERIFY_FAILED: {"tx verify failed", "验证交易失败"},
	ERR_CODE_GET_CHAIN_CONF:   {"get chain conf failed", "获取ChainConf对象失败"},
	ERR_CODE_GET_BLOCKCHAIN:   {"get blockchain failed", "获取Blockchain对象失败"},
	ERR_CODE_GET_STORE:        {"get store failed", "获取store对象失败"},
	ERR_CODE_GET_LAST_BLOCK:   {"get last block failed", "获取最后区块失败失败"},
	ERR_CODE_GET_SUBSCRIBER:   {"get subscriber failed", "获取subscriber对象失败"},
	ERR_CODE_GET_VM_MGR:       {"get vm manager failed", "获取VM Manager失败"},
	ERR_CODE_INVOKE_CONTRACT:  {"invoke contract failed", "VM虚拟机合约失败"},
	ERR_CODE_TXTYPE:           {"unsupport tx_type", "txType不支持"},
}
View Source
var (
	// core
	// Block rw set verify fail txs
	WarnRwSetVerifyFailTxs = JsonError{Code: -31203, Message: "Block rw set verify fail txs"}
)

Functions

This section is empty.

Types

type ErrCode

type ErrCode int32
const (
	ERR_CODE_OK                                           ErrCode = iota
	ERR_CODE_SYSTEM_CONTRACT_PB_UNMARSHAL                 ErrCode = 1000 + iota
	ERR_CODE_SYSTEM_CONTRACT_UNKNOWN_TX_ROUTE_MAP         ErrCode = 1000 + iota
	ERR_CODE_SYSTEM_CONTRACT_UNSUPPORT_CONTRACT_NAME      ErrCode = 1000 + iota
	ERR_CODE_SYSTEM_CONTRACT_UNSUPPORT_METHOD_NAME        ErrCode = 1000 + iota
	ERR_CODE_SYSTEM_CONTRACT_QUERY_FAILED                 ErrCode = 1000 + iota
	ERR_CODE_SYSTEM_CONTRACT_CONTRACT_FAILED              ErrCode = 1000 + iota
	ERR_CODE_CHECK_PAYLOAD_PARAM_SUBSCRIBE_BLOCK          ErrCode = 1000 + iota
	ERR_CODE_CHECK_PAYLOAD_PARAM_SUBSCRIBE_TX             ErrCode = 1000 + iota
	ERR_CODE_CHECK_PAYLOAD_PARAM_SUBSCRIBE_CONTRACT_EVENT ErrCode = 1000 + iota
	ERR_CODE_CHECK_PAYLOAD_PARAM_ARCHIVE_BLOCK            ErrCode = 1000 + iota
	ERR_CODE_TX_ADD_FAILED                                ErrCode = 1000 + iota
	ERR_CODE_TX_VERIFY_FAILED                             ErrCode = 1000 + iota
	ERR_CODE_GET_CHAIN_CONF                               ErrCode = 1000 + iota
	ERR_CODE_GET_BLOCKCHAIN                               ErrCode = 1000 + iota
	ERR_CODE_GET_STORE                                    ErrCode = 1000 + iota
	ERR_CODE_GET_LAST_BLOCK                               ErrCode = 1000 + iota
	ERR_CODE_GET_VM_MGR                                   ErrCode = 1000 + iota
	ERR_CODE_GET_SUBSCRIBER                               ErrCode = 1000 + iota
	ERR_CODE_INVOKE_CONTRACT                              ErrCode = 1000 + iota
	ERR_CODE_TXTYPE                                       ErrCode = 1000 + iota
)

func (ErrCode) Int

func (e ErrCode) Int() int32

func (ErrCode) String

func (e ErrCode) String() string

type Error

type Error interface {
	Error() string  // error information
	ErrorCode() int // error code
}

type JsonError

type JsonError struct {
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

func (JsonError) Error

func (err JsonError) Error() string

func (JsonError) ErrorCode

func (err JsonError) ErrorCode() int

func (JsonError) String

func (err JsonError) String() string

Jump to

Keyboard shortcuts

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