import "github.com/greenbone/opensight-golang-libraries/pkg/errorResponses"
Package errorResponses provides rest api models for errors
const (
ErrorTypeGeneric = errorTypePrefix + "generic-error"
ErrorTypeValidation = errorTypePrefix + "validation-error"
ErrorTypeUpstreamApi = errorTypePrefix + "upstream-api-error"
ErrorTypeApi = errorTypePrefix + "api-error"
ErrorTypeConnection = errorTypePrefix + "connection-error"
)
var ErrorInternalResponse = ErrorResponse{
Type: ErrorTypeGeneric,
Title: "internal error",
}
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(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(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.
Generated by gomarkdoc