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 ¶
- func GetFsError(err error) (error, bool)
- func GetNetError(err error) (netErr net.Error, ok bool)
- func GetRuntimeError(err error) (rErr runtime.Error, ok bool)
- func IsAlreadyExists(err error) bool
- func IsFsError(err error) bool
- func IsNetError(err error) bool
- func IsNotFound(err error) bool
- func IsNotImplemented(err error) bool
- func IsRuntimeError(err error) bool
- func NewAlreadyExists(name string) error
- func NewNotFound(lookingFor string) error
- func NewNotImplemented(feature string) error
- func ToHTTPStatus(err error) int
- type ErrAlreadyExists
- type ErrNotFound
- type ErrNotImplemented
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetFsError ¶ added in v0.0.10
func GetRuntimeError ¶ added in v0.0.10
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
FIXME: this is copy and paste, but can't pass an interface directly
func IsNetError ¶ added in v0.0.10
func IsNotFound ¶ added in v0.0.10
func IsNotImplemented ¶ added in v0.0.10
FIXME: this is copy and paste, but can't pass an interface directly
func IsRuntimeError ¶
func NewAlreadyExists ¶ added in v0.0.10
func NewNotFound ¶ added in v0.0.10
func NewNotImplemented ¶ added in v0.0.10
func ToHTTPStatus ¶ added in v0.0.10
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()
}