apperror

package
v0.0.0-...-b8330c8 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

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

Error is an error with a human-readable message, wrapped error, and transport codes.

func Duplicate

func Duplicate(message string, err error) *Error

Duplicate returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 409 Conflict. For gRPC, the status code is 6 AlreadyExists.

func Internal

func Internal(message string, err error) *Error

Internal returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 500 InternalServerError. For gRPC, the status code is 13 Internal.

func InvalidData

func InvalidData(message string, err error) *Error

InvalidData returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 422 UnprocessableEntity. For gRPC, the status code is 3 InvalidArgument.

func InvalidInput

func InvalidInput(message string, err error) *Error

InvalidInput returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 400 Bad Request. For gRPC, the status code is 3 InvalidArgument.

func New

func New(message string, err error, httpCode int, grpcCode codes.Code) *Error

New returns a new error with the specified human-readable message, HTTP status code, and gRPC error code.

func NotFound

func NotFound(message string, err error) *Error

NotFound returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 404 NotFound. For gRPC, the status code is 5 NotFound.

func OutOfRange

func OutOfRange(message string, err error) *Error

OutOfRange returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 404 NotFound. For gRPC, the status code is 11 OutOfRange.

func Unauthenticated

func Unauthenticated(message string, err error) *Error

Unauthenticated returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 401 Unauthorized. For gRPC, the status code is 16 Unauthenticated.

func Unauthorized

func Unauthorized(message string, err error) *Error

Unauthorized returns an error with a human-readable message and the corresponding transport codes. For HTTP, the status code is 403 Forbidden. For gRPC, the status code is 7 PermissionDenied.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) GrpcCode

func (e *Error) GrpcCode() codes.Code

GrpcCode returns the gRPC error code associated with the error.

func (*Error) HttpCode

func (e *Error) HttpCode() int

HttpCode returns the HTTP status code associated with the error.

func (*Error) Message

func (e *Error) Message() string

Message returns the human-readable message associated with the error along with human-readable message of the wrapped error (if it implements Error).

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap implements the errors.Wrapper interface.

Jump to

Keyboard shortcuts

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