Help us shape the future of Go! Take the 2026 Go Developer Survey

errors

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

shareblocked.go 分享管控拒绝态错误(治理状态机的 typed error 词汇表)。

历史:app/share.ShareBlockedError 与 app/anonymous.BlockedError 曾各持一份 逐字相同的实现(消息文案与 errcode 映射同款,状态常量还一个用 model 常量 一个用字面量,已有漂移),2026-10-10 合并至此;两域以类型别名消费, handler 侧 errors.As / resp.NewTypedError 用法不变。

Index

Constants

View Source
const (
	CodeSuccess            = 0
	CodeBadRequest         = 1001
	CodeUnauthorized       = 1002
	CodeForbidden          = 1003
	CodeNotFound           = 1004
	CodeConflict           = 1005
	CodeInternalError      = 1006
	CodeServiceUnavailable = 1007
	CodeTooManyRequests    = 1008
)
View Source
const (
	ShareStatusBlocked       = "blocked"
	ShareStatusPendingReview = "pending_review"
)

分享治理状态字面量。pkg 层不得 import repo(架构守卫规则 1),故此处独立 定义并与 repo/db/model 的同名常量对齐——app 层测试钉死防漂移断言。

Variables

This section is empty.

Functions

func GetErrorCode

func GetErrorCode(err error) int

func GetMessage

func GetMessage(code int) string

func IsAppError

func IsAppError(err error) bool

Types

type AppError

type AppError struct {
	Code    int
	Message string
	Cause   error
}

func BadRequest

func BadRequest(message string) *AppError

func Conflict

func Conflict(message string) *AppError

func Forbidden

func Forbidden(message string) *AppError

func InternalError

func InternalError(message string) *AppError

func New

func New(code int, message string) *AppError

func NotFound

func NotFound(message string) *AppError

func Unauthorized

func Unauthorized(message string) *AppError

func Wrap

func Wrap(code int, message string, cause error) *AppError

func (*AppError) Error

func (e *AppError) Error() string

func (*AppError) Unwrap

func (e *AppError) Unwrap() error

type ShareBlocked added in v0.15.1

type ShareBlocked struct {
	Status string
}

ShareBlocked 分享处于管控拒绝态(管理员禁用 / 待审核)。 handler 侧按 ErrCode 透传(20012 blocked / 20013 pending_review)。

func (*ShareBlocked) ErrCode added in v0.15.1

func (e *ShareBlocked) ErrCode() int

func (*ShareBlocked) Error added in v0.15.1

func (e *ShareBlocked) Error() string

Jump to

Keyboard shortcuts

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