Documentation
¶
Index ¶
- Variables
- func IsServiceError(err error) bool
- type DoneHandler
- type ErrHandler
- type ServerError
- func (n ServerError) AddHeader(header, value string) ServerError
- func (n ServerError) Cause() error
- func (n ServerError) Error() string
- func (n ServerError) GetHeaders() micro.Headers
- func (n ServerError) GetOptHeaders() micro.RespondOpt
- func (n ServerError) GetWrapped() []byte
- func (n ServerError) SetHeader(header, value string) ServerError
- func (n ServerError) WithHeaders(headers map[string][]string) error
- type ServiceError
- type StatsHandler
Constants ¶
This section is empty.
Variables ¶
var ( ErrMarshallingFailed = errors.New("Failed to marshal proto message") ErrUnmarshallingFailed = errors.New("Failed to unmarshal proto message") )
Predefined Errors
Functions ¶
func IsServiceError ¶ added in v0.1.2
Types ¶
type DoneHandler ¶
DoneHandler is an interface that when implemented on the server, will be used directly instead of having to use the WithDoneHandler option.
type ErrHandler ¶
ErrHandler is an interface that when implemented on the server, will be used directly instead of having to use the WithErrorHandler option.
type ServerError ¶
ServerError is a custom error type that can be used to return a statuscode along with an error description and additional to the client.
func NewServerErr ¶
func NewServerErr(code, description string) ServerError
func WrapServerErr ¶
func WrapServerErr(err error, code, description string) ServerError
func (ServerError) AddHeader ¶
func (n ServerError) AddHeader(header, value string) ServerError
func (ServerError) Cause ¶
func (n ServerError) Cause() error
func (ServerError) Error ¶
func (n ServerError) Error() string
func (ServerError) GetHeaders ¶
func (n ServerError) GetHeaders() micro.Headers
func (ServerError) GetOptHeaders ¶
func (n ServerError) GetOptHeaders() micro.RespondOpt
func (ServerError) GetWrapped ¶
func (n ServerError) GetWrapped() []byte
GetWrapped returns the wrapped error as a byte slice, or nil if there is no wrapped error. It's therefore safe to be used directly in a NATS response, for example, like this: ```request.Error(natsErr.code, natsErr.description, natsErr.GetWrapped())```
func (ServerError) SetHeader ¶
func (n ServerError) SetHeader(header, value string) ServerError
func (ServerError) WithHeaders ¶
func (n ServerError) WithHeaders(headers map[string][]string) error
type ServiceError ¶ added in v0.1.2
type ServiceError struct {
Code, Description, Details string
}
ServiceError is returned when the server returns an error instead of the expected message.
func AsServiceError ¶ added in v0.1.2
func AsServiceError(err error) (ServiceError, bool)
func (ServiceError) Error ¶ added in v0.1.2
func (e ServiceError) Error() string
func (ServiceError) Is ¶ added in v0.1.2
func (e ServiceError) Is(target error) bool
type StatsHandler ¶
StatsHandler is an interface that when implemented on the server, will be used directly instead of having to use the WithStatsHandler option.