pkg

package
v3.4.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 9, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleKnownBusinessValidationErrors added in v3.2.0

func HandleKnownBusinessValidationErrors(err error) error

func ValidateBadRequestFieldsError

func ValidateBadRequestFieldsError(requiredFields, knownInvalidFields map[string]string, entityType string, unknownFields map[string]any) error

ValidateBadRequestFieldsError validates the error and returns the appropriate bad request error code, title, message, and the invalid fields.

Parameters: - requiredFields: A map of missing required fields and their error messages. - knownInvalidFields: A map of known invalid fields and their validation errors. - entityType: The type of the entity associated with the error. - unknownFields: A map of unknown fields and their error messages.

Returns: - An error indicating the validation result, which could be a ValidationUnknownFieldsError or a ValidationKnownFieldsError.

func ValidateBusinessError

func ValidateBusinessError(err error, entityType string, args ...any) error

ValidateBusinessError validates the error and returns the appropriate business error code, title, and message.

Parameters:

Returns:

  • error: The appropriate business error with code, title, and message.

func ValidateInternalError

func ValidateInternalError(err error, entityType string) error

ValidateInternalError validates the error and returns an appropriate InternalServerError.

Parameters: - err: The error to be validated. - entityType: The type of the entity associated with the error.

Returns: - An InternalServerError with the appropriate code, title, message.

func ValidateUnmarshallingError

func ValidateUnmarshallingError(err error) error

ValidateUnmarshallingError validates the error and returns an appropriate ResponseError.

Types

type EntityConflictError

type EntityConflictError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

EntityConflictError records an error indicating an entity already exists in some repository You can use it to represent a Database conflict, cache or any other repository.

func (EntityConflictError) Error

func (e EntityConflictError) Error() string

Error implements the error interface.

func (EntityConflictError) Unwrap

func (e EntityConflictError) Unwrap() error

Unwrap implements the error interface introduced in Go 1.13 to unwrap the internal error.

type EntityNotFoundError

type EntityNotFoundError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

EntityNotFoundError records an error indicating an entity was not found in any case that caused it. You can use it to represent a Database not found, cache not found or any other repository.

func (EntityNotFoundError) Error

func (e EntityNotFoundError) Error() string

Error implements the error interface.

func (EntityNotFoundError) Unwrap

func (e EntityNotFoundError) Unwrap() error

Unwrap implements the error interface introduced in Go 1.13 to unwrap the internal error.

type FailedPreconditionError

type FailedPreconditionError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

FailedPreconditionError indicates a precondition failed during an operation.

func (FailedPreconditionError) Error

func (e FailedPreconditionError) Error() string

type FieldValidations

type FieldValidations map[string]string

FieldValidations is a map of known fields and their validation errors.

type ForbiddenError

type ForbiddenError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

ForbiddenError indicates an operation that couldn't be performed because the authenticated user has no sufficient privileges.

func (ForbiddenError) Error

func (e ForbiddenError) Error() string

type HTTPError

type HTTPError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

HTTPError indicates an http error raised in an http client.

func (HTTPError) Error

func (e HTTPError) Error() string

type InternalServerError

type InternalServerError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

InternalServerError indicates midaz has an unexpected failure during an operation.

func (InternalServerError) Error

func (e InternalServerError) Error() string

type ResponseError

type ResponseError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

ResponseError is a struct used to return errors to the client.

func (ResponseError) Error

func (r ResponseError) Error() string

Error returns the message of the ResponseError.

No parameters. Returns a string.

type UnauthorizedError

type UnauthorizedError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

UnauthorizedError indicates an operation that couldn't be performed because there's no user authenticated.

func (UnauthorizedError) Error

func (e UnauthorizedError) Error() string

type UnknownFields

type UnknownFields map[string]any

UnknownFields is a map of unknown fields and their error messages.

type UnprocessableOperationError

type UnprocessableOperationError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

UnprocessableOperationError indicates an operation that couldn't be performed because it's invalid.

func (UnprocessableOperationError) Error

type ValidationError

type ValidationError struct {
	EntityType string `json:"entityType,omitempty"`
	Title      string `json:"title,omitempty"`
	Message    string `json:"message,omitempty"`
	Code       string `json:"code,omitempty"`
	Err        error  `json:"err,omitempty"`
}

ValidationError records an error indicating some validation have failed in any case that caused it. You can use it to represent a validation error or any other repository.

func (ValidationError) Error

func (e ValidationError) Error() string

Error implements the error interface.

func (ValidationError) Unwrap

func (e ValidationError) Unwrap() error

Unwrap implements the error interface introduced in Go 1.13 to unwrap the internal error.

type ValidationKnownFieldsError

type ValidationKnownFieldsError struct {
	EntityType string           `json:"entityType,omitempty"`
	Title      string           `json:"title,omitempty"`
	Message    string           `json:"message,omitempty"`
	Code       string           `json:"code,omitempty"`
	Err        error            `json:"err,omitempty"`
	Fields     FieldValidations `json:"fields,omitempty"`
}

ValidationKnownFieldsError records an error that occurred during a validation of known fields.

func (ValidationKnownFieldsError) Error

Error returns the error message for a ValidationKnownFieldsError.

No parameters. Returns a string.

type ValidationUnknownFieldsError

type ValidationUnknownFieldsError struct {
	EntityType string        `json:"entityType,omitempty"`
	Title      string        `json:"title,omitempty"`
	Message    string        `json:"message,omitempty"`
	Code       string        `json:"code,omitempty"`
	Err        error         `json:"err,omitempty"`
	Fields     UnknownFields `json:"fields,omitempty"`
}

ValidationUnknownFieldsError records an error that occurred during a validation of unknown fields.

func (ValidationUnknownFieldsError) Error

Error returns the error message for a ValidationUnknownFieldsError.

No parameters. Returns a string.

Directories

Path Synopsis
gold
net

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL