errors

package
v0.0.0-...-643d18f Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package errors 公用的错误信息

Index

Constants

View Source
const (
	SyntaxError int8 = iota + 1
	SyntaxWarn
	Other
)

错误分类

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	LocaleError

	Type  int8
	File  string
	Line  int
	Field string
	// contains filtered or unexported fields
}

Error 错误信息

func New

func New(file, field string, line int, msg message.Reference, vals ...interface{}) *Error

New 声明新的 Error 实例

func WithError

func WithError(err error, file, field string, line int, msg message.Reference, vals ...interface{}) *Error

WithError 返回一条带错误内容的 Error 实例

func (*Error) Error

func (err *Error) Error() string

type Handler

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

Handler 用于接收错误信息内容

func NewHandler

func NewHandler(f HandlerFunc) *Handler

NewHandler 声明新的 Handler 实例

func (*Handler) Stop

func (h *Handler) Stop()

Stop 停止处理错误内容

func (*Handler) SyntaxError

func (h *Handler) SyntaxError(err *Error)

SyntaxError 输出一条语法错误信息

func (*Handler) SyntaxWarn

func (h *Handler) SyntaxWarn(err *Error)

SyntaxWarn 输出一条语法警告信息

type HandlerFunc

type HandlerFunc func(err *Error)

HandlerFunc 错误处理函数

func NewLogHandlerFunc

func NewLogHandlerFunc(errolog, warnlog *log.Logger) HandlerFunc

NewLogHandlerFunc 生成一个将错误信息输出到日志的 HandlerFunc

该实例仅仅是将语法错误和语法警告信息输出到指定的日志通道。

type LocaleError

type LocaleError struct {
	MessageKey  message.Reference
	MessageArgs []interface{}
}

LocaleError 本地化的错误信息

func (*LocaleError) Error

func (err *LocaleError) Error() string

Jump to

Keyboard shortcuts

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