errors

package
v3.1.0-rc.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const UnknownTheCodeStrf = "the error code is '%d', unknown meaning"

UnknownTheCodeStrf const define unknow code

View Source
const UnknownTheLanguageStrf = "the language code is '%s', unknown meaning"

UnknownTheLanguageStrf define unknow language

Variables

View Source
var EmptyErrorsSetting = map[string]ErrorCode{}

EmptyErrorsSetting empty errors setting

Functions

func LoadErrorResourceFromDir

func LoadErrorResourceFromDir(dir string) (map[string]ErrorCode, error)

Types

type CCError

type CCError interface {
	error
}

CCError error interface

type CCErrorCoder

type CCErrorCoder interface {
	error
	// GetCode return the error code
	GetCode() int
}

CCErrorCoder get Error Code

type CCErrorIf

type CCErrorIf interface {
	// CreateDefaultCCErrorIf create new language error interface instance
	CreateDefaultCCErrorIf(language string) DefaultCCErrorIf
	// Error returns an error for specific language
	Error(language string, errCode int) error
	// Errorf Errorf returns an error with args for specific language
	Errorf(language string, errCode int, args ...interface{}) error

	Load(res map[string]ErrorCode)
}

CCErrorIf defines error information conversion

func New

func New(dir string) (CCErrorIf, error)

New create new CCErrorIf instance, dir is directory of errors description resource

func NewFromCtx

func NewFromCtx(errcode map[string]ErrorCode) CCErrorIf

type DefaultCCErrorIf

type DefaultCCErrorIf interface {
	// Error returns an error with error code
	Error(errCode int) error
	// Errorf returns an error with error code
	Errorf(errCode int, args ...interface{}) error

	// New create a new error with error code and message
	New(errorCode int, msg string) error
}

DefaultCCErrorIf defines default error code interface

type ErrorCode

type ErrorCode map[string]string

ErrorCode error code mapping

Jump to

Keyboard shortcuts

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