Documentation
¶
Index ¶
- func EnsureCorrelationID(envelope *errors.ErrorEnvelope, ctx context.Context) *errors.ErrorEnvelope
- func EnsureEnvelope(err error) *errors.ErrorEnvelope
- func HTTPStatusFromCode(code string) int
- func HTTPStatusFromEnvelope(envelope *errors.ErrorEnvelope) int
- func NewConfigInvalidError(message string) *errors.ErrorEnvelope
- func NewConflictError(message string) *errors.ErrorEnvelope
- func NewDataProcessingError(message string) *errors.ErrorEnvelope
- func NewDatabaseError(message string) *errors.ErrorEnvelope
- func NewExternalServiceError(message string) *errors.ErrorEnvelope
- func NewForbiddenError(message string) *errors.ErrorEnvelope
- func NewInternalError(message string) *errors.ErrorEnvelope
- func NewInvalidInputError(message string) *errors.ErrorEnvelope
- func NewMethodNotAllowedError(message string) *errors.ErrorEnvelope
- func NewNotFoundError(message string) *errors.ErrorEnvelope
- func NewTimeoutError(message string) *errors.ErrorEnvelope
- func NewUnauthorizedError(message string) *errors.ErrorEnvelope
- func NewValidationError(message string) *errors.ErrorEnvelope
- func RespondWithEnvelope(w http.ResponseWriter, r *http.Request, envelope *errors.ErrorEnvelope)
- func RespondWithError(w http.ResponseWriter, r *http.Request, err error)
- func ResponseDetails(envelope *errors.ErrorEnvelope) map[string]interface{}
- func WrapConfigInvalid(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapConflict(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapDataProcessing(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapDatabaseError(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapExternalService(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapForbidden(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapInternal(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapInvalidInput(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapNotFound(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapTimeout(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapUnauthorized(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- func WrapValidationError(ctx context.Context, err error, message string) *errors.ErrorEnvelope
- type HTTPErrorDetail
- type HTTPErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnsureCorrelationID ¶
func EnsureCorrelationID(envelope *errors.ErrorEnvelope, ctx context.Context) *errors.ErrorEnvelope
EnsureCorrelationID attaches a correlation ID to the envelope using the context when available.
func EnsureEnvelope ¶
func EnsureEnvelope(err error) *errors.ErrorEnvelope
EnsureEnvelope normalizes any error into a gofulmen ErrorEnvelope.
func HTTPStatusFromCode ¶
HTTPStatusFromCode resolves the HTTP status code corresponding to an error code.
func HTTPStatusFromEnvelope ¶
func HTTPStatusFromEnvelope(envelope *errors.ErrorEnvelope) int
HTTPStatusFromEnvelope resolves the HTTP status code corresponding to an error envelope.
func NewConfigInvalidError ¶
func NewConfigInvalidError(message string) *errors.ErrorEnvelope
func NewConflictError ¶
func NewConflictError(message string) *errors.ErrorEnvelope
func NewDataProcessingError ¶
func NewDataProcessingError(message string) *errors.ErrorEnvelope
Application-Specific Errors
func NewDatabaseError ¶
func NewDatabaseError(message string) *errors.ErrorEnvelope
func NewExternalServiceError ¶
func NewExternalServiceError(message string) *errors.ErrorEnvelope
func NewForbiddenError ¶
func NewForbiddenError(message string) *errors.ErrorEnvelope
func NewInternalError ¶
func NewInternalError(message string) *errors.ErrorEnvelope
Server Errors (500-level)
func NewInvalidInputError ¶
func NewInvalidInputError(message string) *errors.ErrorEnvelope
User Errors (400-level)
func NewMethodNotAllowedError ¶
func NewMethodNotAllowedError(message string) *errors.ErrorEnvelope
func NewNotFoundError ¶
func NewNotFoundError(message string) *errors.ErrorEnvelope
func NewTimeoutError ¶
func NewTimeoutError(message string) *errors.ErrorEnvelope
func NewUnauthorizedError ¶
func NewUnauthorizedError(message string) *errors.ErrorEnvelope
func NewValidationError ¶
func NewValidationError(message string) *errors.ErrorEnvelope
func RespondWithEnvelope ¶
func RespondWithEnvelope(w http.ResponseWriter, r *http.Request, envelope *errors.ErrorEnvelope)
RespondWithEnvelope finalizes the provided envelope, logging and emitting metrics.
func RespondWithError ¶
func RespondWithError(w http.ResponseWriter, r *http.Request, err error)
RespondWithError normalizes the supplied error and writes a JSON response.
func ResponseDetails ¶
func ResponseDetails(envelope *errors.ErrorEnvelope) map[string]interface{}
ResponseDetails constructs API-safe details map by merging envelope details and context.
func WrapConfigInvalid ¶
func WrapConflict ¶
func WrapDataProcessing ¶
func WrapDatabaseError ¶
func WrapExternalService ¶
func WrapForbidden ¶
func WrapInternal ¶
func WrapInvalidInput ¶
func WrapNotFound ¶
func WrapTimeout ¶
func WrapUnauthorized ¶
func WrapValidationError ¶
Types ¶
type HTTPErrorDetail ¶
type HTTPErrorDetail struct {
Code string `json:"code"`
Message string `json:"message"`
Details map[string]interface{} `json:"details,omitempty"`
RequestID string `json:"request_id,omitempty"`
}
HTTPErrorDetail captures the error body returned to callers.
type HTTPErrorResponse ¶
type HTTPErrorResponse struct {
Error HTTPErrorDetail `json:"error"`
}
HTTPErrorResponse wraps HTTPErrorDetail in the standard envelope structure.