rescode

package
v0.0.0-...-cff5d44 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValidationFailed = New(1000, http.StatusUnprocessableEntity, codes.InvalidArgument, "validation_failed")
	Failed           = New(1001, http.StatusInternalServerError, codes.Internal, "failed")
	NotFound         = New(1002, http.StatusNotFound, codes.NotFound, "not_found")
)

Functions

This section is empty.

Types

type R

type R map[string]interface{}

any is a type alias for interface{}. It is used to store any type of data.

type RC

type RC struct {

	// Code is the code of the error.
	Code uint64

	// Message is the message of the error.
	Message string

	// HttpCode is the status code of the error.
	HttpCode int

	// RpcCode is the rpc status code of the error.
	RpcCode codes.Code

	// Data is the data of the error.
	Data any
	// contains filtered or unexported fields
}

RC is a struct that contains the code, message, http status, and translateable. Code is the code of the error.

func (*RC) Error

func (r *RC) Error() string

func (*RC) JSON

func (r *RC) JSON(msgs ...string) map[string]interface{}

JSON is a function to return the RC as a JSON.

func (*RC) OriginalError

func (r *RC) OriginalError() error

func (*RC) SetData

func (r *RC) SetData(data any) *RC

type RcCreator

type RcCreator func(err error) *RC

func New

func New(code uint64, hCode int, rCode codes.Code, message string, data ...any) RcCreator

New is a function to create a new RC.

Jump to

Keyboard shortcuts

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