errortype

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package errortype defines helper for inspect common error types generated in standard library, so you don't need to import tons of packages in your file for sentinel error and custom error type.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFsError added in v0.0.10

func GetFsError(err error) (error, bool)

func GetNetError added in v0.0.10

func GetNetError(err error) (netErr net.Error, ok bool)

func GetRuntimeError added in v0.0.10

func GetRuntimeError(err error) (rErr runtime.Error, ok bool)

RuntimeError is triggered by invalid operation like divide by 0, index out of range in slice. When user call panic, which accepts an interface, most of them will just give a simple string and does not satisfies the runtime.Error interface

func IsAlreadyExists added in v0.0.10

func IsAlreadyExists(err error) bool

FIXME: this is copy and paste, but can't pass an interface directly

func IsFsError added in v0.0.10

func IsFsError(err error) bool

func IsNetError added in v0.0.10

func IsNetError(err error) bool

func IsNotFound added in v0.0.10

func IsNotFound(err error) bool

func IsNotImplemented added in v0.0.10

func IsNotImplemented(err error) bool

FIXME: this is copy and paste, but can't pass an interface directly

func IsRuntimeError

func IsRuntimeError(err error) bool

func NewAlreadyExists added in v0.0.10

func NewAlreadyExists(name string) error

func NewNotFound added in v0.0.10

func NewNotFound(lookingFor string) error

func NewNotImplemented added in v0.0.10

func NewNotImplemented(feature string) error

func ToHTTPStatus added in v0.0.10

func ToHTTPStatus(err error) int

ToHTTPStatus converts error to http code based on their type It is similar to docker's https://github.com/moby/moby/blob/master/errdefs/http_helpers.go TODO: only a few types are supported and the assertions are actually resource consuming due to using reflection

Types

type ErrAlreadyExists added in v0.0.10

type ErrAlreadyExists interface {
	IsErrAlreadyExists()
}

type ErrNotFound added in v0.0.10

type ErrNotFound interface {
	IsErrNotFound()
}

type ErrNotImplemented added in v0.0.10

type ErrNotImplemented interface {
	IsErrNotImplemented()
}

Jump to

Keyboard shortcuts

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