errors

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2021 License: Apache-2.0 Imports: 1 Imported by: 8

Documentation

Overview

Package errors provides the error interface used by Blacksmith and the adapters. It is also the recommended way to handle errors in Blacksmith applications.

To avoid import cycles, this package should not import any other Blacksmith packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {

	// StatusCode is the HTTP status code returned by the caller.
	StatusCode int `json:"statusCode,omitempty"`

	// Message is the error message.
	Message string `json:"message,omitempty"`

	// Validations is a list of validation errors.
	Validations []Validation `json:"validations,omitempty"`

	// Meta includes meta details about the error. It is only used when dealing
	// with HTTP errors to provide a consistent HTTP response across adapters.
	Meta *Meta `json:"meta,omitempty"`
}

Error is used across every Blacksmith packages to normalize error handling. Error implements the standard error interface.

func (*Error) Error

func (err *Error) Error() string

Error returns a stringified representation of the marshalled error. This allows to use Error as a standard error across Blacksmith packages and can be unmarshall by the logrus Logger with custom hooks.

type Event

type Event struct {

	// ID is the generated ID of the event.
	ID string `json:"id"`
}

Event is the representation of an event inside error.

type Meta

type Meta struct {

	// Event contains the fields related to an event when dealing with HTTP errors.
	Event *Event `json:"event,omitempty"`
}

Meta is used when dealing with HTTP errors to provide a consistent HTTP response across adapters.

type Validation

type Validation struct {

	// Message is the error message.
	Message string `json:"message"`

	// Path gives more details about where the error happened.
	Path []string `json:"path"`
}

Validation gives additional info about the parent error. An error can have multiple error validations.

Jump to

Keyboard shortcuts

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