Documentation ¶
Index ¶
- func HasCode(target error, code InsprErrorCode) bool
- func IsIerror(target error) bool
- func Unwrap(err error) error
- type ErrBuilder
- func (b *ErrBuilder) AlreadyExists() *ErrBuilder
- func (b *ErrBuilder) BadRequest() *ErrBuilder
- func (b *ErrBuilder) Build() *InsprError
- func (b *ErrBuilder) Forbidden() *ErrBuilder
- func (b *ErrBuilder) InnerError(err error) *ErrBuilder
- func (b *ErrBuilder) InternalServer() *ErrBuilder
- func (b *ErrBuilder) InvalidApp() *ErrBuilder
- func (b *ErrBuilder) InvalidArgs() *ErrBuilder
- func (b *ErrBuilder) InvalidChannel() *ErrBuilder
- func (b *ErrBuilder) InvalidFile() *ErrBuilder
- func (b *ErrBuilder) InvalidName() *ErrBuilder
- func (b *ErrBuilder) InvalidType() *ErrBuilder
- func (b *ErrBuilder) Message(format string, values ...interface{}) *ErrBuilder
- func (b *ErrBuilder) NotFound() *ErrBuilder
- func (b *ErrBuilder) Unauthorized() *ErrBuilder
- type InsprError
- func (ierror *InsprError) Error() string
- func (ierror *InsprError) HasCode(code InsprErrorCode) bool
- func (ierror *InsprError) Is(target error) bool
- func (ierror *InsprError) MarshalJSON() ([]byte, error)
- func (ierror *InsprError) StackToError()
- func (ierror *InsprError) UnmarshalJSON(data []byte) error
- func (ierror *InsprError) Wrap(message string)
- func (ierror *InsprError) Wrapf(format string, values ...interface{})
- type InsprErrorCode
- type MultiError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasCode ¶
func HasCode(target error, code InsprErrorCode) bool
HasCode checks if an error is an InsprError and if it is,
checks if it has the error code given
Types ¶
type ErrBuilder ¶
type ErrBuilder struct {
// contains filtered or unexported fields
}
ErrBuilder is an Inspr Error Creator
func (*ErrBuilder) AlreadyExists ¶
func (b *ErrBuilder) AlreadyExists() *ErrBuilder
AlreadyExists adds Already Exists code to Inspr Error
func (*ErrBuilder) BadRequest ¶
func (b *ErrBuilder) BadRequest() *ErrBuilder
BadRequest adds Bad Request code to Inspr Error
func (*ErrBuilder) Build ¶
func (b *ErrBuilder) Build() *InsprError
Build returns the created Inspr Error
func (*ErrBuilder) Forbidden ¶
func (b *ErrBuilder) Forbidden() *ErrBuilder
Forbidden adds Forbidden code to Inspr Error
func (*ErrBuilder) InnerError ¶
func (b *ErrBuilder) InnerError(err error) *ErrBuilder
InnerError adds a inner error to the error
func (*ErrBuilder) InternalServer ¶
func (b *ErrBuilder) InternalServer() *ErrBuilder
InternalServer adds Internal Server code to Inspr Error
func (*ErrBuilder) InvalidApp ¶
func (b *ErrBuilder) InvalidApp() *ErrBuilder
InvalidApp adds Invalid App code to Inspr Error
func (*ErrBuilder) InvalidArgs ¶
func (b *ErrBuilder) InvalidArgs() *ErrBuilder
InvalidArgs adds Invalid Args code to Inspr Error
func (*ErrBuilder) InvalidChannel ¶
func (b *ErrBuilder) InvalidChannel() *ErrBuilder
InvalidChannel adds Invalid Channel code to Inspr Error
func (*ErrBuilder) InvalidFile ¶
func (b *ErrBuilder) InvalidFile() *ErrBuilder
InvalidFile adds Invalid Args code to Inspr Error
func (*ErrBuilder) InvalidName ¶
func (b *ErrBuilder) InvalidName() *ErrBuilder
InvalidName adds Invalid Name code to Inspr Error
func (*ErrBuilder) InvalidType ¶
func (b *ErrBuilder) InvalidType() *ErrBuilder
InvalidType adds Invalid Type code to Inspr Error
func (*ErrBuilder) Message ¶
func (b *ErrBuilder) Message(format string, values ...interface{}) *ErrBuilder
Message adds a message to the error
func (*ErrBuilder) NotFound ¶
func (b *ErrBuilder) NotFound() *ErrBuilder
NotFound adds Not Found code to Inspr Error
func (*ErrBuilder) Unauthorized ¶
func (b *ErrBuilder) Unauthorized() *ErrBuilder
Unauthorized adds Unauthorized code to Inspr Error
type InsprError ¶
type InsprError struct { Message string `yaml:"message" json:"message"` Err error `yaml:"_" json:"_"` Stack string `yaml:"stack" json:"stack"` Code InsprErrorCode `yaml:"code" json:"code"` }
InsprError is an error that happened inside inspr
func (*InsprError) Error ¶
func (ierror *InsprError) Error() string
Error returns the InsprError Message
func (*InsprError) HasCode ¶
func (ierror *InsprError) HasCode(code InsprErrorCode) bool
HasCode Compares error with error code
func (*InsprError) MarshalJSON ¶
func (ierror *InsprError) MarshalJSON() ([]byte, error)
MarshalJSON a struct function that allows for operations to be done before or after the json.Marshal procedure
func (*InsprError) StackToError ¶
func (ierror *InsprError) StackToError()
StackToError converts the following structure of a error stack message into an actual stack of errors using the fmt.Errorf
func (*InsprError) UnmarshalJSON ¶
func (ierror *InsprError) UnmarshalJSON(data []byte) error
UnmarshalJSON a struct function that allows for operations to be done before or after the json.Unmarshal procedure
func (*InsprError) Wrap ¶
func (ierror *InsprError) Wrap(message string)
Wrap adds a message to the ierror stack
func (*InsprError) Wrapf ¶
func (ierror *InsprError) Wrapf(format string, values ...interface{})
Wrapf adds the format with the values given to the ierror stack
type InsprErrorCode ¶
type InsprErrorCode int32
InsprErrorCode is error codes for inspr errors
const ( NotFound InsprErrorCode = 1 << iota AlreadyExists InternalServer InvalidName InvalidApp InvalidChannel InvalidType InvalidFile InvalidArgs BadRequest InvalidToken ExpiredToken Forbidden )
Error codes for inspr errors
type MultiError ¶
type MultiError struct { Errors []error Code InsprErrorCode }
MultiError is a type that handles multiple errors that can happen in a process
func (*MultiError) Empty ¶
func (e *MultiError) Empty() bool
Empty returns if there is no error in the multierror
func (*MultiError) Error ¶
func (e *MultiError) Error() (ret string)
Error return the errors in the multierror concatenated with new lines