iotex-core: github.com/iotexproject/iotex-core/ioctl/output Index | Files

package output

import "github.com/iotexproject/iotex-core/ioctl/output"

Index

Package Files

format.go

Variables

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

type Output Uses

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

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

Package output imports 3 packages (graph) and is imported by 10 packages. Updated 2019-11-21. Refresh now. Tools for package owners.