errors

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2022 License: MIT Imports: 2 Imported by: 45

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMap = map[ErrCode]string{
	Success: "succeed",
	ErrFail: "failed",

	ErrBlockFailure: FormatErrString(prefixBlock, "",
		"unknown"),

	ErrBlockSerializeDeserialize: FormatErrString(prefixBlock, prefixSerialize,
		"serialize/deserialize failed"),

	ErrBlockValidation: FormatErrString(prefixBlock, prefixValidate,
		"validation failed"),
	ErrBlockIneffectiveCoinbase: FormatErrString(prefixBlock, prefixValidate,
		"coinbase transaction is invalid"),

	ErrTxFailure: FormatErrString(prefixTx, "", "unknown"),

	ErrTxSerializeDeserialize: FormatErrString(prefixTx, prefixSerialize,
		"serialize/deserialize failed"),

	ErrTxValidation: FormatErrString(prefixTx, prefixValidate,
		"validation failed"),
	ErrTxInvalidInput: FormatErrString(prefixTx, prefixValidate,
		"input invalid"),
	ErrTxInvalidOutput: FormatErrString(prefixTx, prefixValidate,
		"output invalid"),
	ErrTxBalance: FormatErrString(prefixTx, prefixValidate,
		"balance not matched"),
	ErrTxAttributeProgram: FormatErrString(prefixTx, prefixValidate,
		"attribute or program content invalid"),
	ErrTxSignature: FormatErrString(prefixTx, prefixValidate,
		"signature invalid"),
	ErrTxPayload: FormatErrString(prefixTx, prefixValidate,
		"payload content invalid"),
	ErrTxDoubleSpend: FormatErrString(prefixTx, prefixValidate,
		"double spend"),
	ErrTxSize: FormatErrString(prefixTx, prefixValidate,
		"size over the limit"),
	ErrTxUnknownReferredTx: FormatErrString(prefixTx, prefixValidate,
		"unknown referred transaction"),
	ErrTxUTXOLocked: FormatErrString(prefixTx, prefixValidate,
		"using locked UTXO"),
	ErrTxDuplicate: FormatErrString(prefixTx, prefixValidate,
		"transaction already exist"),
	ErrTxHeightVersion: FormatErrString(prefixTx, prefixValidate,
		"height version invalid"),
	ErrTxAssetPrecision: FormatErrString(prefixTx, prefixValidate,
		"asset precision invalid"),
	ErrTxReturnDeposit: FormatErrString(prefixTx, prefixValidate,
		"return deposit content invalid"),
	ErrTxAppropriation: FormatErrString(prefixTx, prefixValidate,
		"appropriation invalid"),
	ErrTxAssetsRectify: FormatErrString(prefixTx, prefixValidate,
		"asset rectify invalid"),
	ErrTxRealWithdraw: FormatErrString(prefixTx, prefixValidate,
		"real withdraw invalid"),
	ErrTxCRCRClaimNode: FormatErrString(prefixTx, prefixValidate,
		"CRC claim node invalid"),
	ErrTxRevertToPOW: FormatErrString(prefixTx, prefixValidate,
		"revert to POW invalid"),
	ErrTxReturnSideChainDeposit: FormatErrString(prefixTx, prefixValidate,
		"return side chain deposit coin invalid"),

	ErrTxSidechainValidation: FormatErrString(prefixTx, prefixSidechain,
		"unknown"),
	ErrTxSidechainDuplicate: FormatErrString(prefixTx, prefixSidechain,
		"already exist"),
	ErrTxSidechainPowConsensus: FormatErrString(prefixTx, prefixSidechain,
		"pow consensus invalid"),

	ErrDPoSFailure: FormatErrString(prefixDPoS, "", "unknown"),

	ErrCRFailure: FormatErrString(prefixCR, "", "unknown"),

	ErrDbFailure: FormatErrString(prefixDatabase, "",
		"unknown"),

	ErrP2pFailure: FormatErrString(prefixP2p, "", "unknown"),

	ErrP2pReject: FormatErrString(prefixP2p, prefixReject, "unknown"),
	ErrP2pRejectMalformed: FormatErrString(prefixP2p, prefixReject,
		"malformed message"),
	ErrP2pRejectInvalid: FormatErrString(prefixP2p, prefixReject,
		"invalid message"),
	ErrP2pRejectObsolete: FormatErrString(prefixP2p, prefixReject,
		"obsoleted protocol"),
	ErrP2pRejectDuplicate: FormatErrString(prefixP2p, prefixReject,
		"duplicated message"),
	ErrP2pRejectNonstandard: FormatErrString(prefixP2p, prefixReject,
		"message is not standard"),
	ErrP2pRejectDust: FormatErrString(prefixP2p, prefixReject,
		"dust message"),
	ErrP2pRejectInsufficientFee: FormatErrString(prefixP2p, prefixReject,
		"insufficient fee"),
	ErrP2pRejectCheckpoint: FormatErrString(prefixP2p, prefixReject,
		"invalid checkpoint"),

	ErrPoolFailure: FormatErrString(prefixPool, "", "unknown"),

	ErrTxPoolFailure: FormatErrString(prefixPool, prefixTxPool,
		"unknown"),
	ErrTxPoolOverCapacity: FormatErrString(prefixPool, prefixTxPool,
		"over capacity"),
	ErrTxPoolSidechainTxDuplicate: FormatErrString(prefixPool, prefixTxPool,
		"sidechain transaction already exist"),
	ErrTxPoolDPoSTxDuplicate: FormatErrString(prefixPool, prefixTxPool,
		"DPoS transaction conflict"),
	ErrTxPoolCRTxDuplicate: FormatErrString(prefixPool, prefixTxPool,
		"CR transaction conflict"),
	ErrTxPoolDoubleSpend: FormatErrString(prefixPool, prefixTxPool,
		"double spend with transaction in transaction pool"),
}

Functions

func FormatErrString added in v0.5.0

func FormatErrString(mainClass, subClass, message string) string

Types

type ELAError added in v0.5.0

type ELAError interface {
	error

	Code() ErrCode
	InnerError() error
}

type ErrCode

type ErrCode int
const (
	Success ErrCode = 0
	ErrFail ErrCode = -1

	// 1-block
	ErrBlockFailure ErrCode = -10000
	// 11 serialize
	ErrBlockSerializeDeserialize ErrCode = -11000
	// 12 check
	ErrBlockValidation          ErrCode = -12000
	ErrBlockIneffectiveCoinbase ErrCode = -12001

	// 2-transaction
	ErrTxFailure ErrCode = -20000
	// 21 serialize
	ErrTxSerializeDeserialize ErrCode = -21000
	// 22 check
	ErrTxValidation             ErrCode = -22000
	ErrTxInvalidInput           ErrCode = -22001
	ErrTxInvalidOutput          ErrCode = -22002
	ErrTxBalance                ErrCode = -22003
	ErrTxAttributeProgram       ErrCode = -22004
	ErrTxSignature              ErrCode = -22005
	ErrTxPayload                ErrCode = -22006
	ErrTxDoubleSpend            ErrCode = -22007
	ErrTxSize                   ErrCode = -22008
	ErrTxUnknownReferredTx      ErrCode = -22009
	ErrTxUTXOLocked             ErrCode = -22010
	ErrTxDuplicate              ErrCode = -22011
	ErrTxHeightVersion          ErrCode = -22012
	ErrTxAssetPrecision         ErrCode = -22013
	ErrTxReturnDeposit          ErrCode = -22014
	ErrTxAppropriation          ErrCode = -22015
	ErrTxAssetsRectify          ErrCode = -22016
	ErrTxRealWithdraw           ErrCode = -22017
	ErrTxCRCRClaimNode          ErrCode = -22018
	ErrTxRevertToPOW            ErrCode = -22019
	ErrTxReturnSideChainDeposit ErrCode = -22020
	// 23 sidechain
	ErrTxSidechainValidation   ErrCode = -23000
	ErrTxSidechainDuplicate    ErrCode = -23001
	ErrTxSidechainPowConsensus ErrCode = -23002

	// 3-DPoS
	ErrDPoSFailure ErrCode = -30000

	// 4-CR
	ErrCRFailure ErrCode = -40000

	// 5-Database
	ErrDbFailure ErrCode = -50000

	// 6-P2P
	ErrP2pFailure ErrCode = -60000
	// 61 reject
	ErrP2pReject                ErrCode = -61000
	ErrP2pRejectMalformed       ErrCode = -61001
	ErrP2pRejectInvalid         ErrCode = -61002
	ErrP2pRejectObsolete        ErrCode = -61003
	ErrP2pRejectDuplicate       ErrCode = -61004
	ErrP2pRejectNonstandard     ErrCode = -61005
	ErrP2pRejectDust            ErrCode = -61006
	ErrP2pRejectInsufficientFee ErrCode = -61007
	ErrP2pRejectCheckpoint      ErrCode = -61008

	// 7-pool
	ErrPoolFailure ErrCode = -70000
	// 71 tx pool
	ErrTxPoolFailure              ErrCode = -71000
	ErrTxPoolOverCapacity         ErrCode = -71001
	ErrTxPoolSidechainTxDuplicate ErrCode = -71002
	ErrTxPoolDPoSTxDuplicate      ErrCode = -71003
	ErrTxPoolCRTxDuplicate        ErrCode = -71004
	ErrTxPoolDoubleSpend          ErrCode = -71005
	ErrTxPoolTypeCastFailure      ErrCode = -71006
	ErrTxPoolTxDuplicate          ErrCode = -71007
)

type JsonFormatter added in v0.5.0

type JsonFormatter struct {
	Code        int            `json:"Code"`
	Description string         `json:"Description"`
	Inner       *JsonFormatter `json:"Inner"`
}

func ToJsonFormatter added in v0.5.0

func ToJsonFormatter(err ELAError) *JsonFormatter

func (*JsonFormatter) Format added in v0.5.0

func (f *JsonFormatter) Format() (string, error)

type SimpleErr added in v0.5.0

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

func Simple added in v0.5.0

func Simple(code ErrCode, inner error) *SimpleErr

func SimpleWithMessage added in v0.5.0

func SimpleWithMessage(code ErrCode, inner error, message string) *SimpleErr

func (*SimpleErr) Code added in v0.5.0

func (e *SimpleErr) Code() ErrCode

func (*SimpleErr) Error added in v0.5.0

func (e *SimpleErr) Error() string

func (*SimpleErr) InnerError added in v0.5.0

func (e *SimpleErr) InnerError() error

Jump to

Keyboard shortcuts

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