Documentation ¶
Overview ¶
Package errorResponses provides rest api models for errors
Index ¶
Constants ¶
View Source
const ( ErrorTypeGeneric = errorTypePrefix + "generic-error" ErrorTypeValidation = errorTypePrefix + "validation-error" ErrorTypeUpstreamApi = errorTypePrefix + "upstream-api-error" ErrorTypeApi = errorTypePrefix + "api-error" ErrorTypeConnection = errorTypePrefix + "connection-error" )
Variables ¶
View Source
var ErrorInternalResponse = ErrorResponse{ Type: ErrorTypeGeneric, Title: "internal error", }
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Type string `json:"type"` Title string `json:"title"` Details string `json:"details,omitempty"` Errors map[string]string `json:"errors,omitempty"` }
func NewErrorGenericResponse ¶
func NewErrorGenericResponse(message ...any) ErrorResponse
NewErrorGenericResponse returns a ErrorResponse of type Generic with the given error message. The message is handled the same as fmt.Println.
func NewErrorValidationResponse ¶
func NewErrorValidationResponse(title, details string, errors map[string]string) ErrorResponse
NewErrorValidationResponse returns a ErrorResponse of type Validation. `errors` is a mapping from field name to error message for this specific field.
Click to show internal directories.
Click to hide internal directories.