bolterror

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MPL-2.0 Imports: 1 Imported by: 4

Documentation

Overview

Package bolterror provides the methods by which an error is defined and formatted for communication back to the API caller.

Index

Constants

View Source
const (
	Internal = iota //An error within the engine logic/operation itself
	Request         //An error related to an incoming/in-process API call
	Timeout         //Call or command wasnt completed before the allocated timeout period
	Zombie          //Last command wasn't completed before allocated 'zombie' give-up time. In a healthy system these shouldn't happen
)

ErrType constants for NewBoltError. DO NOT CHANGE THE ORDER! Always add a new type at the bottom of the list

Variables

This section is empty.

Functions

This section is empty.

Types

type BoltError

type BoltError struct {
	Srcerr  error
	Parent  string
	Details string
	Input   string
	ErrType int
}

BoltError is the wrapper for an error that needs to be communicated back to the API caller. It is recommended that it not be created directly, but via the NewBoltError function

func NewBoltError

func NewBoltError(err error, parent string, details string, input string, errtype int) *BoltError

NewBoltError creates a BoltError struct using an optional source error and other details. The Parent parameter is used to differentiate this error from other errors in the event that a response contains multiple errors.

func (*BoltError) AddToPayload

func (e *BoltError) AddToPayload(payload *gabs.Container)

AddToPayload takes a gabs JSON container and adds this error's contents to the container in JSON format. The format is:

"error": {
    BoltError.Parent {
        "details": BoltError.Details,
        "type": BoltError.ErrType,
        "input": BoltError.Input,
    }
}

Jump to

Keyboard shortcuts

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