neterr

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package neterr seeks to unify error formatting for API consumers. All CodedErrors have a code (int) that is unique to that error within your API and a message (string) that describes what the error means.

Index

Constants

This section is empty.

Variables

View Source
var DefaultOptionsHeaderSetError = newVialError(
	4,
	"Error while settings headers in options route.",
)

DefaultOptionsHeaderSetError occurs when there is a problem setting the headers in the DefaultOptions route.

View Source
var MethodNotAllowedError = newVialError(
	1,
	"Method not allowed.",
)

MethodNotAllowedErrror is send when a method that is not setup is called on a route that exists.

View Source
var RouteNotSetupError = newVialError(
	2,
	"Route specified has not been setup.",
)

RouteNotSetupError is an error that occurs when a route was called that hasn't been setup.

View Source
var SwaggerNotFoundError = newVialError(
	3,
	"Couldn't find swagger file.",
)

SwaggerNotFoundError is an error that occurs when the swagger does not exist.

Functions

This section is empty.

Types

type CodedError

type CodedError struct {
	// contains filtered or unexported fields
}

CodedError is an error with a code and a message. It is used to standardize error responses for a uniform API consumer experience. Some special errors are Vial-specific errors which are noted by having a true return value from the IsVialError method call.

func CodedErrorFromError

func CodedErrorFromError(code int, err error) CodedError

CodedErrorFromError is a helper that takes a go error and formats it into a proper CodedError.

func NewCodedError

func NewCodedError(code int, message string) CodedError

NewCodedError creates a new CodedError.

func (*CodedError) Code

func (self *CodedError) Code() int

Code returns the error code for the CodedError.

func (*CodedError) IsVialError

func (self *CodedError) IsVialError() bool

IsVialError specifies whether this error is a framework-level error or not.

func (CodedError) MarshalJSON

func (self CodedError) MarshalJSON() ([]byte, error)

func (*CodedError) Message

func (self *CodedError) Message() string

Message returns the message attached to the CodedError.

func (*CodedError) UnmarshalJSON

func (self *CodedError) UnmarshalJSON(data []byte) error

Jump to

Keyboard shortcuts

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