Documentation ¶
Index ¶
- Constants
- Variables
- func Configure(f func(*Config))
- func GetId(e Error) (string, bool)
- func GetPrecondition(e Error) (string, bool)
- func GetReason(e Error) (string, bool)
- func GetResource(e Error) (string, bool)
- func GetValidationErrors(e Error) (map[string]string, bool)
- func Is(err error, template Template) bool
- func Message(str string) func(params map[string]any) string
- func New(template Template, params ...Param) error
- func Wrap(err error, template Template, params ...Param) error
- type Code
- type Config
- type Error
- func (e *Error) Cause() error
- func (e *Error) Code() Code
- func (e *Error) Error() string
- func (e *Error) Get(key string) any
- func (e Error) MarshalJSON() ([]byte, error)
- func (e Error) MarshalXML(en *xml.Encoder, start xml.StartElement) error
- func (e *Error) Params() Params
- func (e *Error) StackTrace() StackTrace
- func (e *Error) UnmarshalJSON(bytes []byte) error
- func (e *Error) UnmarshalXML(d *xml.Decoder, _ xml.StartElement) error
- func (e *Error) Unwrap() error
- type Frame
- type Param
- type Params
- type StackTrace
- type Template
Constants ¶
View Source
const CodeChecksumError = "ChecksumError"
Variables ¶
View Source
var AlreadyExists = Template{ Code: CodeAlreadyExists, Message: func(params map[string]any) string { resource, found := params[keyResource] if !found { return "Resource already exists" } return fmt.Sprintf("%s already exists", resource) }, Params: Params{}, }
View Source
var AlreadyInProgress = Template{ Code: CodeAlreadyInProgress, Message: func(params map[string]any) string { return "Already in progress" }, Params: Params{}, }
View Source
var BlockingLink = Template{ Code: CodeBlockingLink, Message: func(params map[string]any) string { return "There are links to this resource" }, Params: Params{}, }
View Source
var ChecksumError = Template{ Code: CodeChecksumError, Message: func(params map[string]any) string { return "Checksum does not match" }, Params: Params{}, }
View Source
var Forbidden = Template{ Code: CodeForbidden, Message: func(params map[string]any) string { return fmt.Sprintf("Forbidden") }, Params: Params{}, }
View Source
var IllegalState = Template{ Code: CodeIllegalState, Message: func(params map[string]any) string { reason, found := params[keyReason] if !found { return "Illegal state" } return fmt.Sprintf("Illegal state: %s", reason) }, Params: Params{}, }
View Source
var InternalError = Template{ Code: CodeInternalError, Message: func(params map[string]any) string { return "Internal error" }, Params: Params{}, }
View Source
var NotFound = Template{ Code: CodeNotFound, Message: func(params map[string]any) string { resource, found := params[keyResource] if !found { return "Resource not found" } return fmt.Sprintf("%s not found", resource) }, Params: Params{}, }
View Source
var NotImplemented = Template{ Code: CodeNotImplemented, Message: func(params map[string]any) string { return "Not implemented" }, Params: Params{}, }
View Source
var PreconditionFailed = Template{ Code: CodePreconditionFailed, Message: func(params map[string]any) string { precondition, found := params[keyPrecondition] if !found { return "Precondition failed" } return fmt.Sprintf("Precondition %s failed", precondition) }, Params: Params{}, }
View Source
var PreconditionRequired = Template{ Code: CodePreconditionFailed, Message: func(params map[string]any) string { precondition, found := params[keyPrecondition] if !found { return "Precondition required" } return fmt.Sprintf("Precondition %s required", precondition) }, Params: Params{}, }
View Source
var Timeout = Template{ Code: CodeTimeout, Message: Message(`Timeout`), Params: Params{}, }
View Source
var ToManyRequests = Template{ Code: CodeToManyRequests, Message: Message("To many request, please reduce your requests rate"), }
View Source
CodeUnauthorized, Message: func(params map[string]any) string { return fmt.Sprintf("Unauthorized") }, Params: Params{}, }Code:
View Source
var ValidationError = Template{ Code: CodeValidationError, Message: func(params map[string]any) string { resource, found := params[keyResource] if !found { return "Resource validation error" } return fmt.Sprintf("%s validation error", resource) }, Params: Params{}, }
Functions ¶
func GetPrecondition ¶
func GetResource ¶
Types ¶
type Code ¶
type Code string
const CodeAlreadyExists Code = "AlreadyExists"
const CodeAlreadyInProgress Code = "AlreadyInProgress"
const CodeBlockingLink Code = "BlockingLink"
const CodeForbidden Code = "Forbidden"
const CodeIllegalState Code = "IllegalState"
const CodeInternalError Code = "InternalError"
const CodeNotFound Code = "NotFound"
const CodeNotImplemented Code = "NotImplemented"
const CodePreconditionFailed Code = "PreconditionFailed"
const CodePreconditionRequired Code = "PreconditionRequired"
const CodeTimeout Code = "Timeout"
const CodeToManyRequests Code = "ToManyRequests"
const CodeValidationError Code = "ValidationError"
type Config ¶
type Config struct { CollectStackTrace bool IsPrivateParam func(name string) bool MarshalJsonKey func(name string) string MarshalJsonParam map[string]func(value any) ([]byte, error) UnmarshalJsonKey func(name string) string UnmarshalJsonParam map[string]func(data []byte) (any, error) MarshalXMLKey func(name string) string MarshalXmlParam map[string]func(en *xml.Encoder, start xml.StartElement, value any) error UnmarshalXMLKey func(name string) string UnmarshalXmlParam map[string]func(d *xml.Decoder, start xml.StartElement) (any, error) MarshalCause bool MarshalStackTrace bool }
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func (Error) MarshalJSON ¶
func (Error) MarshalXML ¶
func (*Error) StackTrace ¶
func (e *Error) StackTrace() StackTrace
func (*Error) UnmarshalJSON ¶
func (*Error) UnmarshalXML ¶
type Param ¶
func WithPrecondition ¶
func WithReason ¶
func WithResource ¶
func WithValidationErrors ¶
type StackTrace ¶
type StackTrace []Frame
func (StackTrace) String ¶
func (s StackTrace) String() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.