Documentation ¶
Index ¶
- func Error(err error, code string, opts ...HandlerOption) error
- func ErrorWithContext(ctx context.Context, err error, code string, opts ...HandlerOption) error
- func SetDisplayErrorURL(flag bool)
- func SetDisplayedSuggestions(num int)
- func SetErrorParentPath(parentDir string)
- func SetLogger(logger *log.Logger)
- func SetManifest(content []byte)
- func SetManifestFilename(filepath string)
- func SetMarkdownRender(markdown bool)
- func SetOverrideErrorURL(url string)
- func SetShowShortSummary(flag bool)
- func SetSilence(silence bool)
- type Handler
- func (w *Handler) Error(err error, code string, opts ...HandlerOption) error
- func (w *Handler) ErrorWithContext(ctx context.Context, err error, code string, opts ...HandlerOption) error
- func (w *Handler) SetDisplayErrorURL(flag bool)
- func (w *Handler) SetDisplayedSuggestions(num int)
- func (w *Handler) SetErrorParentPath(parentDir string)
- func (w *Handler) SetLogger(logger *log.Logger)
- func (w *Handler) SetManifest(content []byte)
- func (w *Handler) SetManifestFilename(filepath string)
- func (w *Handler) SetMarkdownRender(markdown bool)
- func (w *Handler) SetOverrideErrorURL(url string)
- func (w *Handler) SetShowShortSummary(flag bool)
- func (w *Handler) SetSilence(silence bool)
- type HandlerOption
- func WithDisplayErrorURL(flag bool) HandlerOption
- func WithErrorParentPath(parentDir string) HandlerOption
- func WithLogger(logger *log.Logger) HandlerOption
- func WithManifest(source []byte) HandlerOption
- func WithManifestFilename(filename string) HandlerOption
- func WithNoLogger() HandlerOption
- func WithNumberOfSuggestions(num int) HandlerOption
- func WithOverrideErrorURL(url string) HandlerOption
- func WithRenderMarkdown(markdown bool) HandlerOption
- func WithShowShortSummary(flag bool) HandlerOption
- func WithSilence(silence bool) HandlerOption
- type HandlerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(err error, code string, opts ...HandlerOption) error
Error wraps the incoming error with error defined by the application error manifest according to the input code. if no error is found in the application error manifest, the original error is returned.
func ErrorWithContext ¶
ErrorWithContext wraps the incoming error with error defined by the application error manifest according to the input code. if no error is found in the application error manifest, the original error is returned.
func SetDisplayedSuggestions ¶
func SetDisplayedSuggestions(num int)
func SetErrorParentPath ¶
func SetErrorParentPath(parentDir string)
func SetManifest ¶
func SetManifest(content []byte)
func SetManifestFilename ¶
func SetManifestFilename(filepath string)
func SetMarkdownRender ¶
func SetMarkdownRender(markdown bool)
func SetSilence ¶
func SetSilence(silence bool)
Types ¶
type Handler ¶
type Handler struct {
Options *HandlerOptions
}
Handler is the wrapper struct for errors
func New ¶
func New(opts ...HandlerOption) *Handler
New creates and configures a new instance of the error handler.
example:
errHandler := New(WithManifest("content"),WithNoLogger(),WithRenderMarkdown(true))
errHandler.Error(err, "error code")
func (*Handler) Error ¶
func (w *Handler) Error(err error, code string, opts ...HandlerOption) error
Error wraps the incoming error with error defined by the application error manifest according to the input code. if no error is found in the application error manifest, the original error is returned.
func (*Handler) ErrorWithContext ¶
func (w *Handler) ErrorWithContext(ctx context.Context, err error, code string, opts ...HandlerOption) error
ErrorWithContext wraps the incoming error with error defined by the Aloe specification according to the input code. if no error is found in the specification, the original error is returned.
func (*Handler) SetDisplayErrorURL ¶
SetDisplayErrorURL
func (*Handler) SetDisplayedSuggestions ¶
SetDisplayedSuggestions
func (*Handler) SetErrorParentPath ¶
SetErrorParentPath
func (*Handler) SetLogger ¶
SetLogger sets the logger used by the Handler internally. note: pass nil if no logging is wanted
func (*Handler) SetManifest ¶
SetManifest sets the source manifest used by the Handler note: it is not required if the SetManifestFilename is set
func (*Handler) SetManifestFilename ¶
SetManifestFilename sets the file path of the manifest used by the Handler. note: it is not required if SetManifest is set
func (*Handler) SetMarkdownRender ¶
SetMarkdownRender
func (*Handler) SetOverrideErrorURL ¶
SetOverrideErrorURL
func (*Handler) SetShowShortSummary ¶
SetShowShortSummary
type HandlerOption ¶
type HandlerOption func(o *HandlerOptions)
HandlerOption is a more atomic to configure the different HandlerOptions rather than passing the entire ErrClientOptions struct.
func WithDisplayErrorURL ¶
func WithDisplayErrorURL(flag bool) HandlerOption
func WithErrorParentPath ¶
func WithErrorParentPath(parentDir string) HandlerOption
func WithLogger ¶
func WithLogger(logger *log.Logger) HandlerOption
func WithManifest ¶
func WithManifest(source []byte) HandlerOption
func WithManifestFilename ¶
func WithManifestFilename(filename string) HandlerOption
func WithNoLogger ¶
func WithNoLogger() HandlerOption
func WithNumberOfSuggestions ¶
func WithNumberOfSuggestions(num int) HandlerOption
func WithOverrideErrorURL ¶
func WithOverrideErrorURL(url string) HandlerOption
func WithRenderMarkdown ¶
func WithRenderMarkdown(markdown bool) HandlerOption
func WithShowShortSummary ¶
func WithShowShortSummary(flag bool) HandlerOption
func WithSilence ¶
func WithSilence(silence bool) HandlerOption
type HandlerOptions ¶
type HandlerOptions struct { // Logger is internal Logger for the wrapper, leave nil to avoid logging Logger *log.Logger // Silent globally sets the error handler to stop adding the additional error context in the input error of Error() and ErrorWithContext() Silent bool errorclient.ErrClientOptions }
HandlerOptions contains all the different configuration values available to the wrapper