fielderr

package
v0.0.0-...-82802e3 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeBadRequest = iota
	CodeNotFound
	CodeInternal
	CodeUnauthorized
	CodeConflict
	CodeForbidden
	CodeNoContent
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error is custom error that is using in service to deliver error to controllers with prepared statuses and log fields.

func New

func New(msg string, data any, code int, fields ...zap.Field) *Error

New creates new error with provided fields.

func (*Error) Code

func (f *Error) Code() int

Code return internal code.

func (*Error) CodeGRPC

func (f *Error) CodeGRPC() codes.Code

CodeGRPC returns grpc status Code that is equal to custom one.

func (*Error) CodeHTTP

func (f *Error) CodeHTTP() int

CodeHTTP returns http Code that is equal to custom one.

func (*Error) Data

func (f *Error) Data() any

Data return data to return to user.

func (*Error) ErrGRPC

func (f *Error) ErrGRPC() error

ErrGRPC returns prepared grpc error with msg message and correct grpc code.

func (*Error) Error

func (f *Error) Error() string

Error return error message.

func (*Error) Fields

func (f *Error) Fields() []zap.Field

Fields return zap fields.

func (*Error) Unwrap

func (f *Error) Unwrap() error

Unwrap make available to use errors.Is with *Error.

func (*Error) With

func (f *Error) With(fields ...zap.Field) *Error

With create new error object that copies error fields instead of Fields

Jump to

Keyboard shortcuts

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