# README

errorResponses

import "github.com/greenbone/opensight-golang-libraries/pkg/errorResponses"

Package errorResponses provides rest api models for errors

Index

Constants

const (
    ErrorTypeGeneric     = errorTypePrefix + "generic-error"
    ErrorTypeValidation  = errorTypePrefix + "validation-error"
    ErrorTypeUpstreamApi = errorTypePrefix + "upstream-api-error"
    ErrorTypeApi         = errorTypePrefix + "api-error"
    ErrorTypeConnection  = errorTypePrefix + "connection-error"
)

Variables

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

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.

Generated by gomarkdoc

# Functions

NewErrorGenericResponse returns a [ErrorResponse] of type Generic with the given error message.
NewErrorValidationResponse returns a [ErrorResponse] of type Validation.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Variables

No description provided by the author

# Structs

No description provided by the author