Documentation ¶
Overview ¶
Package errors defines some well defined errors, like incomplete/wrong request data or object not found(404), for the purpose of internationalization.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotAuthorized = errors.New("rooms/web: not authorized") ErrDenied = errors.New("rooms: this key has been banned") )
Functions ¶
This section is empty.
Types ¶
type DatabaseError ¶
type DatabaseError struct{ Reason error }
func (DatabaseError) Error ¶
func (e DatabaseError) Error() string
type ErrBadRequest ¶
func (ErrBadRequest) Error ¶
func (br ErrBadRequest) Error() string
func (ErrBadRequest) Unwrap ¶
func (err ErrBadRequest) Unwrap() error
type ErrForbidden ¶
type ErrForbidden struct{ Details error }
func (ErrForbidden) Error ¶
func (f ErrForbidden) Error() string
type ErrGenericLocalized ¶
type ErrGenericLocalized struct{ Label string }
ErrGenericLocalized is used for one-off errors that primarily are presented for the user. The contained label is passed to the i18n engine for translation.
func (ErrGenericLocalized) Error ¶
func (err ErrGenericLocalized) Error() string
type ErrNotFound ¶
type ErrNotFound struct{ What string }
func (ErrNotFound) Error ¶
func (nf ErrNotFound) Error() string
type ErrRedirect ¶
ErrRedirect is used when the controller decides to not render a page
func (ErrRedirect) Error ¶
func (err ErrRedirect) Error() string
func (ErrRedirect) Unwrap ¶
func (err ErrRedirect) Unwrap() error
type ErrorHandler ¶
type ErrorHandler struct {
// contains filtered or unexported fields
}
func NewErrorHandler ¶
func NewErrorHandler(locHelper *i18n.Helper, flashes *FlashHelper) *ErrorHandler
func (*ErrorHandler) Handle ¶
func (eh *ErrorHandler) Handle(rw http.ResponseWriter, req *http.Request, code int, err error)
func (*ErrorHandler) SetRenderer ¶
func (eh *ErrorHandler) SetRenderer(r *render.Renderer)
SetRenderer needs to update the rendere later since we need to pass ErrorHandler into render.New (ie. befor we get the pointer for r)
type FlashHelper ¶
type FlashHelper struct {
// contains filtered or unexported fields
}
func NewFlashHelper ¶
func NewFlashHelper(s sessions.Store, loc *i18n.Helper) *FlashHelper
func (FlashHelper) AddError ¶
func (fh FlashHelper) AddError(rw http.ResponseWriter, req *http.Request, err error)
AddError adds a FlashError and translates the passed err using localizeError()
func (FlashHelper) AddMessage ¶
func (fh FlashHelper) AddMessage(rw http.ResponseWriter, req *http.Request, label string)
AddMessage expects a i18n label, translates it and adds it as a FlashNotification
func (FlashHelper) GetAll ¶
func (fh FlashHelper) GetAll(rw http.ResponseWriter, req *http.Request) ([]FlashMessage, error)
GetAll returns all the FlashMessages, emptys and updates the store
type FlashKind ¶
type FlashKind uint
const ( // FlashError signals that a problem occured FlashError FlashKind // FlashNotification represents a normal message (like "xyz added/updated successfull") FlashNotification )
type FlashMessage ¶
type PageNotFound ¶
type PageNotFound struct{ Path string }
func (PageNotFound) Error ¶
func (e PageNotFound) Error() string