Documentation
¶
Index ¶
- func BadRequest(c *app.RequestContext, msg string)
- func Conflict(c *app.RequestContext, msg string)
- func InternalError(c *app.RequestContext, msg string)
- func InternalErrorLog(ctx context.Context, c *app.RequestContext, op string, err error)
- func MapError(c *app.RequestContext, err error, mappings []ErrorMapping)
- func NotFound(c *app.RequestContext, msg string)
- type ErrResponse
- type ErrorMapping
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BadRequest ¶
func BadRequest(c *app.RequestContext, msg string)
BadRequest sends a 400 response with code=-1.
func Conflict ¶
func Conflict(c *app.RequestContext, msg string)
Conflict sends a 409 response with code=-1.
func InternalError ¶
func InternalError(c *app.RequestContext, msg string)
InternalError sends a 500 response with code=-1. The msg is sent verbatim to the client.
func InternalErrorLog ¶
InternalErrorLog logs the underlying err with op context and returns the full error to the client. Per the project convention (AGENTS.md: "错误信息就要全量 给用户显示,不要隐藏任何错误信息") quartet runs in a trusted environment, so surfacing the real error — paths included — beats forcing the user to dig through backend logs.
func MapError ¶
func MapError(c *app.RequestContext, err error, mappings []ErrorMapping)
MapError checks err against a list of mappings and sends the appropriate HTTP response. Whether or not a mapping matches, the full error message is returned to the client (AGENTS.md: errors must be shown in full); a matched mapping only changes the HTTP status code.
func NotFound ¶
func NotFound(c *app.RequestContext, msg string)
NotFound sends a 404 response with code=-1.
Types ¶
type ErrResponse ¶
ErrResponse is the standard error response envelope. Uses "msg" field to match existing frontend convention.
type ErrorMapping ¶
ErrorMapping maps sentinel errors to HTTP status codes.