merror

package
v0.0.0-...-e2755d2 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToGRPCError

func ToGRPCError(e error) error

ToGRPCError converts merror to grpc status error

Types

type Code

type Code uint32

Code is internal error code type

const (
	// OK is returned on success.
	OK Code = 0
	// Canceled indicates the operation was canceled (typically by the caller).
	Canceled Code = 1
	// Unknown error errors raised by APIs that do not return enough error information
	// may be converted to this error.
	Unknown Code = 2
	// InvalidArgument indicates client specified an invalid argument.
	InvalidArgument Code = 3
	// DeadlineExceeded means operation expired before completion.
	DeadlineExceeded Code = 4
	// NotFound means some requested entity (e.g., file or directory) was
	// not found.
	// This error code will not be generated by the gRPC framework.
	NotFound Code = 5
	// AlreadyExists means an attempt to create an entity failed because one
	// already exists.
	AlreadyExists Code = 6
	// PermissionDenied indicates the caller does not have permission to
	// execute the specified operation.
	PermissionDenied Code = 7
	// ResourceExhausted indicates some resource has been exhausted, perhaps
	// a per-user quota, or perhaps the entire file system is out of space.
	ResourceExhausted Code = 8
	// FailedPrecondition indicates operation was rejected because the
	// system is not in a state required for the operation's execution.
	// For example, directory to be deleted may be non-empty, an rmdir
	// operation is applied to a non-directory, etc.
	FailedPrecondition Code = 9
	// Aborted indicates the operation was aborted, typically due to a
	// concurrency issue like sequencer check failures, transaction aborts,
	// etc.
	Aborted Code = 10
	// OutOfRange means operation was attempted past the valid range.
	// E.g., seeking or reading past end of file.
	OutOfRange Code = 11
	// Unimplemented indicates operation is not implemented or not
	// supported/enabled in this service.
	Unimplemented Code = 12
	// Internal errors. Means some invariants expected by underlying
	// system has been broken. If you see one of these errors,
	// something is very broken.
	Internal Code = 13
	// Unavailable indicates the service is currently unavailable.
	// This is a most likely a transient condition and may be corrected
	// by retrying with a backoff. Note that it is not always safe to retry
	// non-idempotent operations.
	Unavailable Code = 14
	// DataLoss indicates unrecoverable data loss or corruption.
	DataLoss Code = 15
	// Unauthenticated indicates the request does not have valid
	// authentication credentials for the operation.
	Unauthenticated Code = 16
)

type MError

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

MError is metro error

func New

func New(code Code, msg string) *MError

New returns a merror with code and a message

func Newf

func Newf(code Code, format string, arg ...interface{}) *MError

Newf returns a merror with code and a formatted message

func (*MError) Code

func (e *MError) Code() Code

Code returns the error code

func (*MError) Error

func (e *MError) Error() string

Error returns the error message

func (*MError) ToGRPCError

func (e *MError) ToGRPCError() error

ToGRPCError returns the grpc error

Jump to

Keyboard shortcuts

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