custom

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoValidUser = &Error{
		Message: "No Valid User",
		Status:  http.StatusUnauthorized,
	}
	ErrUserLoginRequired = &Error{
		Message: "User Login Required",
		Status:  http.StatusForbidden,
		Toast:   "登录后即可操作",
		Code:    "E101",
	}
	ErrUserBanned = &Error{
		Message: "User Banned",
		Status:  http.StatusForbidden,
	}
	ErrResourceNotFound = &Error{
		Message: "Resource Not Found",
		Status:  http.StatusNotFound,
	}
	ErrBadRequest = &Error{
		Message: "Bad Request",
		Status:  http.StatusBadRequest,
		Toast:   "参数错误",
	}
	ErrPaymentError = &Error{
		Message: "Payment Service Error",
		Status:  http.StatusBadRequest,
		Toast:   "支付失败",
	}
	ErrIAPError = &Error{
		Message: "IAP Error",
		Status:  http.StatusBadRequest,
	}
	ErrNotBindPhoneNumber = &Error{
		Message: "Need Binding Phone Number",
		Status:  http.StatusForbidden,
		Toast:   "请先绑定手机号哦",
	}
	ErrSponsorRequired = &Error{
		Message: "Sponsor Required",
		Status:  http.StatusForbidden,
		Toast:   "请先开通即刻会员",
	}
	ErrNotFound = &Error{
		Message: "Not Found",
		Status:  http.StatusNotFound,
	}
)

Functions

This section is empty.

Types

type Error

type Error struct {
	Message  string      `json:"message,omitempty"`
	Status   int         `json:"-"`
	GRPCCode codes.Code  `json:"-"`
	Toast    string      `json:"toast,omitempty"`
	Code     string      `json:"code,omitempty"`
	Err      error       `json:"-"`
	Data     interface{} `json:"data,omitempty"`
}

func (*Error) Error

func (c *Error) Error() string

func (*Error) GRPCStatus

func (c *Error) GRPCStatus() *status.Status

func (*Error) Unwrap

func (c *Error) Unwrap() error

func (*Error) WithData

func (c *Error) WithData(d interface{}) *Error

func (*Error) WithError

func (c *Error) WithError(err error) *Error

func (*Error) WithToast

func (c *Error) WithToast(s string) *Error

type ResponseCommon

type ResponseCommon struct {
	Success bool        `json:"success,omitempty"`
	Error   string      `json:"error,omitempty"`
	Message string      `json:"message,omitempty"`
	Toast   string      `json:"toast,omitempty"`
	Data    interface{} `json:"data,omitempty"`
}

Jump to

Keyboard shortcuts

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