errors

package
v0.0.0-...-2db71d7 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

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

	// sync
	ErrSyncServiceHasStarted = JsonError{Code: -33000, Message: "The sync service has been started"} // The sync service has been started
	ErrSyncServiceHasStoped  = JsonError{Code: -33001, Message: "The sync service has been stoped"}  // The sync service has been stoped
)
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不支持"},
}

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