iotex-core: Index | Files

package output

import ""


Package Files



var Format string

Format is the target of output-format flag

func FormatString Uses

func FormatString(t MessageType, m Message) string

FormatString returns Output as string in certain format

func FormatStringWithTrans Uses

func FormatStringWithTrans(t MessageType, m MessageWithTranslation) string

FormatStringWithTrans returns Output as string in certain format supporting multi languages

func JSONString Uses

func JSONString(out interface{}) string

JSONString returns json string for message

func NewError Uses

func NewError(code ErrorCode, info string, pre error) error

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 Uses

func PrintError(err error) error

PrintError prints Error Message in format, only used at top layer of a command

func PrintQuery Uses

func PrintQuery(query string)

PrintQuery prints query message in format

func PrintResult Uses

func PrintResult(result string)

PrintResult prints result message in format

type ConfirmationMessage Uses

type ConfirmationMessage struct {
    Info    string   `json:"info"`
    Options []string `json:"options"`

ConfirmationMessage is the struct of an Confirmation output

func (*ConfirmationMessage) String Uses

func (m *ConfirmationMessage) String() string

type ErrorCode Uses

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
    // RuntimeError used when an error occurs in runtime
    // NetworkError used when an network error is happened
    // APIError used when an API error is happened
    // ValidationError used when validation is not passed
    // SerializationError used when marshal or unmarshal meets error
    // ReadFileError used when error occurs during reading a file
    // WriteFileError used when error occurs during writing a file
    // FlagError used when invalid flag is set
    // ConvertError used when fail to converting data
    // CryptoError used when crypto error occurs
    // AddressError used if an error is related to address
    // InputError used when error about input occurs
    // KeystoreError used when an error related to keystore
    // ConfigError used when an error about config occurs
    // InstantiationError used when an error during instantiation
    // CompilerError used when an error occurs when using the solidity compiler

type ErrorMessage Uses

type ErrorMessage struct {
    Code ErrorCode `json:"code"`
    Info string    `json:"info"`

ErrorMessage is the struct of an Error output

func (ErrorMessage) Error Uses

func (m ErrorMessage) Error() string

Error implements error interface

func (*ErrorMessage) String Uses

func (m *ErrorMessage) String() string

type Message Uses

type Message interface {
    String() string

Message is the message part of output

type MessageType Uses

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
    // Query represents request for answer of certain question
    // Error represents error occurred when running a command
    // Warn represents non-fatal mistake occurred when running a command

type MessageWithTranslation Uses

type MessageWithTranslation interface {
    String(args ...string) string

MessageWithTranslation is the message part of output supporting multi languages

type Output Uses

type Output struct {
    MessageType            MessageType            `json:"messageType"`
    Message                Message                `json:"message"`
    MessageWithTranslation MessageWithTranslation `json:"messageWithTranslation"`

Output is used for format output

type StringMessage Uses

type StringMessage string

StringMessage is the Message for string

func (StringMessage) Query Uses

func (m StringMessage) Query() string

Query prints query message

func (StringMessage) String Uses

func (m StringMessage) String() string

func (StringMessage) Warn Uses

func (m StringMessage) Warn() string

Warn prints warn message

Package output imports 3 packages (graph) and is imported by 12 packages. Updated 2020-05-31. Refresh now. Tools for package owners.