errorstate

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: MIT Imports: 0 Imported by: 9

Documentation

Overview

Package errorstate contains structs to keep multiple error details.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detail

type Detail struct {
	// Domain is unique identifier for the use case raising this error.
	// This helps distinguish usecase-specific errors.
	Domain string `json:"domain,omitempty"`
	// Indicates how the location property should be interpreted.
	Type string `json:"type,omitempty"`
	// The location of the error (the interpretation of its value depends on type).
	Location string `json:"location,omitempty"`
	// Unique identifier for this error.
	Reason string `json:"reason,omitempty"`
	// A human readable message providing more details about the error.
	Message string `json:"message,omitempty"`
}

Detail contains information about error specifics.

type ErrorState

type ErrorState struct {
	// Domain is unique identifier for the use case raising this error.
	Domain string `json:"-"`
	// Error details accociated with this error.
	Errors []*Detail `json:"errors,omitempty"`
}

ErrorState contains information about domain raising this error and any accociated error details.

func Single

func Single(d *Detail) *ErrorState

Single constructs ErrorState with a single Detail.

func (*ErrorState) Add

func (e *ErrorState) Add(d *Detail)

Add detail related to this error.

func (*ErrorState) Error

func (e *ErrorState) Error() string

Error returns a string representation.

func (*ErrorState) OrNil

func (e *ErrorState) OrNil() error

OrNil returns nil if there is no errors added to this state, otherwise returns error.

Jump to

Keyboard shortcuts

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