MCPcopy
hub / github.com/pocketbase/pocketbase / NewApiError

Function NewApiError

tools/router/error.go:120–131  ·  view source on GitHub ↗

NewApiError creates and returns new normalized ApiError instance.

(status int, message string, rawErrData any)

Source from the content-addressed store, hash-verified

118
119// NewApiError creates and returns new normalized ApiError instance.
120func NewApiError(status int, message string, rawErrData any) *ApiError {
121 if message == "" {
122 message = http.StatusText(status)
123 }
124
125 return &ApiError{
126 rawData: rawErrData,
127 Data: safeErrorsData(rawErrData),
128 Status: status,
129 Message: strings.TrimSpace(inflector.Sentenize(message)),
130 }
131}
132
133// ToApiError wraps err into ApiError instance (if not already).
134func ToApiError(err error) *ApiError {

Callers 11

NewApiErrorFunction · 0.92
ErrorMethod · 0.70
NewNotFoundErrorFunction · 0.70
NewBadRequestErrorFunction · 0.70
NewForbiddenErrorFunction · 0.70
NewUnauthorizedErrorFunction · 0.70
NewInternalServerErrorFunction · 0.70
NewTooManyRequestsErrorFunction · 0.70

Calls 2

SentenizeFunction · 0.92
safeErrorsDataFunction · 0.85

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…