MCPcopy Create free account
hub / github.com/astercloud/aster / Error

Function Error

pkg/server/response.go:42–52  ·  view source on GitHub ↗

Error 辅助函数:发送错误响应

(w http.ResponseWriter, status int, code, message string)

Source from the content-addressed store, hash-verified

40
41// Error 辅助函数:发送错误响应
42func Error(w http.ResponseWriter, status int, code, message string) {
43 w.Header().Set("Content-Type", "application/json; charset=utf-8")
44 w.WriteHeader(status)
45 _ = json.NewEncoder(w).Encode(&APIResponse{
46 Success: false,
47 Error: &APIError{
48 Code: code,
49 Message: message,
50 },
51 })
52}
53
54// ErrorWithDetails 辅助函数:发送带详细信息的错误响应
55func ErrorWithDetails(w http.ResponseWriter, status int, code, message, details string) {

Callers 6

BadRequestFunction · 0.70
NotFoundFunction · 0.70
InternalErrorFunction · 0.70
UnauthorizedFunction · 0.70
ForbiddenFunction · 0.70
ConflictFunction · 0.70

Calls 1

SetMethod · 0.65

Tested by

no test coverage detected