yadaerror

package
v0.0.0-...-1c8973f Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2019 License: MIT Imports: 1 Imported by: 3

Documentation

Index

Constants

View Source
const (
	INTERNAL_ERROR = 500
	BAD_REQUEST    = 400
	BAD_ROUTE      = 404
)

supported HTTP error codes

View Source
const (
	UNKNOWN_DOWNLOAD_TYPE = 4001
	UNKNOWN_DOWNLOAD_ID   = 4002
	INVALID_ROUTE         = 4040
)

internal error codes that map to 4xx HTTP codes

View Source
const (
	HTTP_READ_BODY_FAILED = 5001
	JSON_UNMARSHAL_FAILED = 5002
	JSON_MARSHAL_FAILED   = 5003
	RANDOM_READ_FAILED    = 5004
	HTTP_GET_FAILED       = 5005
	FILE_CREATE_FAILED    = 5005
	FILE_COPY_FAILED      = 5006
	DIR_CREATE_FAILED     = 5007
	DIR_STAT_FAILED       = 5008
)

internal error codes that map to 5xx HTTP codes

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	InternalCode int    `json:"internal_code"`
	Message      string `json:"message"`
}

Error is custom error type that implements error. It additionally holds internal codes

func New

func New(msg string, internalCode int) Error

New returns a new Error

func (Error) Error

func (h Error) Error() string

Error is the overriden function

func (Error) ToJSONBytes

func (h Error) ToJSONBytes() []byte

ToJSONBytes marshals Error to json

Jump to

Keyboard shortcuts

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