Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WriteError ¶
func WriteError(ctx context.Context, w http.ResponseWriter, errs ...error)
Write sets the HTTP response status code and body on the response A request ID will be included if available If the error response code is 500 or higher, the error will be recorded in the span
Types ¶
type Error ¶
type Error struct {
Code int `json:"-"`
Message string `json:"message"`
Details string `json:"details,omitempty"`
}
type ErrorResponse ¶
type ErrorResponse struct {
RequestID string `json:"requestID,omitempty"`
Errors []Error `json:"errors"`
Code int `json:"-"`
}
ErrorResponse is a collection of errors intended to standardize error responses
func NewErrorResponse ¶
func NewErrorResponse(requestID string, errs ...error) *ErrorResponse
NewErrorResponse creates a new error response with the given request ID and errors it returns the highest HTTP status code found in the errors, defaulting to 500 Internal Server Error Errors from this package are included in the response If there are no errors that are from this package a default error is used
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
Error joins the messages from the inner errors in the ErrorResponse