errors

package
v0.0.0-...-bee09c4 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FileTooBigCode = "FileTooBig"

FileTooBigCode text code

View Source
const ForbiddenCode = "Forbidden"

ForbiddenCode text code

View Source
const InternalErrorCode = "InternalError"

InternalErrorCode text code

View Source
const InvalidBodyCode = "InvalidBody"

InvalidBodyCode ...

View Source
const InvalidParameterCode = "InvalidParameter"

InvalidParameterCode ...

View Source
const NotFoundCode = "NotFound"

NotFoundCode ...

View Source
const RequestTimeoutCode = "RequestTimeout"

RequestTimeoutCode ...

View Source
const UnauthorizedCode = "Unauthorized"

UnauthorizedCode ...

Variables

This section is empty.

Functions

func Conflict

func Conflict(err error) error

Conflict ...

func FileTooBig

func FileTooBig(err error) error

FileTooBig ...

func Forbidden

func Forbidden(err error) error

Forbidden ...

func InternalError

func InternalError(err error) error

InternalError ...

func InvalidBody

func InvalidBody(err error) error

InvalidBody ...

func InvalidParameter

func InvalidParameter(err error) error

InvalidParameter ...

func IsConflict

func IsConflict(err error) bool

IsConflict ...

func IsFileTooBig

func IsFileTooBig(err error) bool

IsFileTooBig ...

func IsForbidden

func IsForbidden(err error) bool

IsForbidden ...

func IsInternalError

func IsInternalError(err error) bool

IsInternalError ...

func IsInvalidBody

func IsInvalidBody(err error) bool

IsInvalidBody ...

func IsInvalidParameter

func IsInvalidParameter(err error) bool

IsInvalidParameter ...

func IsNotFound

func IsNotFound(err error) bool

IsNotFound ...

func IsRequestTimeout

func IsRequestTimeout(err error) bool

IsRequestTimeout ...

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized ...

func New

func New(message string) error

New Generates a New Error

func NotFound

func NotFound(err error) error

NotFound ...

func RequestTimeout

func RequestTimeout(err error) error

RequestTimeout ...

func Unauthorized

func Unauthorized(err error) error

Unauthorized ...

func Wrap

func Wrap(err error, message string) error

Wrap encapsulates an error for forming stacktrace

Types

type APIError

type APIError interface {
	Code() string
	Message() string
}

APIError is the interface that encapsulates all API HTTP Errors

type ErrorStack

type ErrorStack struct {
	LOC      int    `json:"loc"`
	File     string `json:"file"`
	Package  string `json:"package"`
	FuncName string `json:"func_name"`
}

ErrorStack .

type Fault

type Fault struct {
	Type    string `json:"type"`
	Code    int    `json:"code"`
	Details string `json:"details"`
	// contains filtered or unexported fields
}

Fault .

func Create

func Create(code int, err string) *Fault

Create .

func (*Fault) Error

func (e *Fault) Error() string

Error return more information about the cause

func (*Fault) GetAgent

func (e *Fault) GetAgent(c *gin.Context) string

GetAgent return the currenct agent (browser/mobile, etc) who begins the request

func (*Fault) GetClientIP

func (e *Fault) GetClientIP(c *gin.Context) string

GetClientIP return the current client ip who begins the request

func (*Fault) GetCode

func (e *Fault) GetCode() int

GetCode return the http code status to identify errors focused on the http request flow

func (*Fault) GetDetails

func (e *Fault) GetDetails() string

GetDetails return more information about the error

func (*Fault) GetEndpoint

func (e *Fault) GetEndpoint(c *gin.Context) string

GetEndpoint return the current request endpoint for the current context where was produced the error

func (*Fault) GetErrorStack

func (e *Fault) GetErrorStack() []*ErrorStack

GetErrorStack return the current service where was produced the error

func (*Fault) GetMethod

func (e *Fault) GetMethod(c *gin.Context) string

GetMethod return the current request method for the current context where was produced the error

func (*Fault) GetProgramCode

func (e *Fault) GetProgramCode(c *gin.Context) string

GetProgramCode return the current program_code of the current request

func (*Fault) GetSequence

func (e *Fault) GetSequence(c *gin.Context) int64

GetSequence return a sequence used to identify in what step happens the error

func (*Fault) GetTrackingID

func (e *Fault) GetTrackingID(c *gin.Context) string

GetTrackingID return a unique identifier used to attach the whole request between microservices

func (*Fault) GetType

func (e *Fault) GetType() string

GetType return the log type (error|warning|info|debug)

func (*Fault) GetUserID

func (e *Fault) GetUserID(c *gin.Context) string

GetUserID return the current user_id who begins the request

func (*Fault) Notify

func (e *Fault) Notify() *Fault

Notify allows to send an email notification when some errors it's really important to fix.

func (*Fault) StackTrace

func (e *Fault) StackTrace() *Fault

StackTrace return much more information about where was generated the current error, information such as name of microservice or package, line of code, file and caller's name function. This information is getting from execution time.

Jump to

Keyboard shortcuts

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