Documentation ¶
Index ¶
- Variables
- func FormatString(t MessageType, m Message) string
- func JSONString(out interface{}) string
- func NewError(code ErrorCode, info string, pre error) error
- func PrintError(err error) error
- func PrintQuery(query string)
- func PrintResult(result string)
- type ConfirmationMessage
- type ErrorCode
- type ErrorMessage
- type Message
- type MessageType
- type Output
- type StringMessage
Constants ¶
This section is empty.
Variables ¶
var Format string
Format is the target of output-format flag
Functions ¶
func FormatString ¶
func FormatString(t MessageType, m Message) string
FormatString returns Output as string in certain format
func JSONString ¶
func JSONString(out interface{}) string
JSONString returns json string for message
func NewError ¶
NewError and returns golang error that contains Error Message ErrorCode can pass zero only when previous error is always a format error that contains non-zero error code. ErrorCode passes 0 means that I want to use previous error's code rather than override it. If there is no previous error, newInfo should not be empty.
func PrintError ¶
PrintError prints Error Message in format, only used at top layer of a command
Types ¶
type ConfirmationMessage ¶
ConfirmationMessage is the struct of an Confirmation output
func (*ConfirmationMessage) String ¶
func (m *ConfirmationMessage) String() string
type ErrorCode ¶
type ErrorCode int
ErrorCode is the code of error
const ( // UndefinedError used when an error cat't be classified UndefinedError ErrorCode = iota // UpdateError used when an error occurs when running update command UpdateError // RuntimeError used when an error occurs in runtime RuntimeError // NetworkError used when an network error is happened NetworkError // APIError used when an API error is happened APIError // ValidationError used when validation is not passed ValidationError // SerializationError used when marshal or unmarshal meets error SerializationError // ReadFileError used when error occurs during reading a file ReadFileError // WriteFileError used when error occurs during writing a file WriteFileError // FlagError used when invalid flag is set FlagError // ConvertError used when fail to converting data ConvertError // CryptoError used when crypto error occurs CryptoError // AddressError used if an error is related to address AddressError // InputError used when error about input occurs InputError // KeystoreError used when an error related to keystore KeystoreError // ConfigError used when an error about config occurs ConfigError // InstantiationError used when an error during instantiation InstantiationError )
type ErrorMessage ¶
ErrorMessage is the struct of an Error output
func (*ErrorMessage) String ¶
func (m *ErrorMessage) String() string
type MessageType ¶
type MessageType int
MessageType marks the type of output message
const ( // Result represents the result of a command Result MessageType = iota // Confirmation represents request for confirmation Confirmation // Query represents request for answer of certain question Query // Error represents error occured when running a command Error )
type Output ¶
type Output struct { MessageType MessageType `json:"messageType"` Message Message `json:"message"` }
Output is used for format output
type StringMessage ¶
type StringMessage string
StringMessage is the Message for string
func (StringMessage) String ¶
func (m StringMessage) String() string