message

package
v6.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package message 各类输出消息的处理

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler 异步的消息处理机制

包含了本地化的信息,输出时,会以指定的本地化内容输出

func NewHandler

func NewHandler(f HandlerFunc) *Handler

NewHandler 声明新的 Handler 实例

func (*Handler) Error

func (h *Handler) Error(t Type, err error)

Error 将一条错误信息作为消息发送出去

func (*Handler) Message

func (h *Handler) Message(t Type, key message.Reference, val ...interface{})

Message 发送普通的文本信息,内容由 key 和 val 组成本地化信息

func (*Handler) Stop

func (h *Handler) Stop()

Stop 停止处理错误内容

只有在消息处理完成之后,才会返回。

type HandlerFunc

type HandlerFunc func(*Message)

HandlerFunc 错误处理函数

type Message

type Message struct {
	Type    Type
	Message string
}

Message 输出消息的具体结构

type SyntaxError

type SyntaxError struct {
	Message string
	File    string
	Line    int
	Field   string
}

SyntaxError 表示语法错误信息

无论是配置文件的错误,还是文档的语法错误,都将返回此错误。 apidoc 的错误基本上都是基于 SyntaxError。

func NewLocaleError

func NewLocaleError(file, field string, line int, msg message.Reference, val ...interface{}) *SyntaxError

NewLocaleError 本地化的错误信息

其中的 msg 和 val 会被转换成本地化的内容保存。

func WithError

func WithError(file, field string, line int, err error) *SyntaxError

WithError 声明 SyntaxError 实例,其中的提示信息由 err 返回

func (*SyntaxError) Error

func (err *SyntaxError) Error() string

type Type

type Type int8

Type 表示氐的类型

const (
	Erro Type = iota
	Warn
	Info
	Succ
)

消息的分类

func (Type) String

func (t Type) String() string

Directories

Path Synopsis
Package messagetest 提供测试生成 message 相关的测试工具
Package messagetest 提供测试生成 message 相关的测试工具

Jump to

Keyboard shortcuts

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