result

package
v0.0.0-...-a87a6b4 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var OK = Result{
	Code: CodeOK,
	Info: make(Info),
}

OK represents the success result

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode int
const (
	CodeOK ErrorCode = 0

	// Common Errors
	CodeGenericError             ErrorCode = 100000
	CodeInvalidSignature         ErrorCode = 100001
	CodeInvalidSequence          ErrorCode = 100002
	CodeInsufficientFund         ErrorCode = 100003
	CodeEmptyPubKeyWithSequence1 ErrorCode = 100004
	CodeUnauthorizedTx           ErrorCode = 100005
	CodeInvalidFee               ErrorCode = 100006

	// ReserveFund Errors
	CodeReserveFundCheckFailed   ErrorCode = 101001
	CodeReservedFundNotSpecified ErrorCode = 101002
	CodeInvalidFundToReserve     ErrorCode = 101003

	// ReleaseFund Errors
	CodeReleaseFundCheckFailed ErrorCode = 102001

	// ServerPayment Errors
	CodeCheckTransferReservedFundFailed ErrorCode = 103001

	// SplitRule Errors
	CodeUnauthorizedToUpdateSplitRule ErrorCode = 104001

	// SmartContract Errors
	CodeEVMError               ErrorCode = 105001
	CodeInvalidValueToTransfer ErrorCode = 105002
	CodeInvalidGasPrice        ErrorCode = 105003
	CodeFeeLimitTooHigh        ErrorCode = 105004
	CodeInvalidGasLimit        ErrorCode = 105005

	// Stake Deposit/Withdrawal Errors
	CodeInvalidStakePurpose     ErrorCode = 106001
	CodeInvalidStake            ErrorCode = 106002
	CodeInsufficientStake       ErrorCode = 106003
	CodeNotEnoughBalanceToStake ErrorCode = 106004
	CodeStakeExceedsCap         ErrorCode = 106005
)

type Info

type Info map[string]interface{}

type Result

type Result struct {
	Code    ErrorCode
	Message string
	Info    Info
}

Result represents the result of a function execution

func Error

func Error(msgFormat string, a ...interface{}) Result

Error returns an error result

func OKWith

func OKWith(info Info) Result

OKWith returns a success result with extra information

func (Result) IsError

func (res Result) IsError() bool

IsError indicates if the execution results in an error

func (Result) IsOK

func (res Result) IsOK() bool

IsOK indicates if the execution succeeded

func (Result) String

func (res Result) String() string

String returns the string representation of the result

func (Result) WithErrorCode

func (res Result) WithErrorCode(code ErrorCode) Result

WithErrorCode attach the error code to the result

func (Result) WithMessage

func (res Result) WithMessage(message string) Result

WithMessage appends the result's message with the given message

Jump to

Keyboard shortcuts

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