1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-07 20:17:05 +00:00

Update sessions/sessiondb/badger to its latest version and SessionController is able to initialize itself if session manager is not provided by the caller-dev.

Changes:

Update the badger database using transactions, as supported from yesterday via: 06242925c2

Add a custom `OnActivate` via mvc/activator/activate_listener.go, this can be used to perform any custom actions when the app registers the supported Controllers. See mvc/session_controller.go for the excellent use case.

errors.Reporter.AddErr returns true if the error is added to the stack, otherwise false


Former-commit-id: c896a2d186a4315643f3c5fdb4325f7ee48a9e0a
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-10-06 01:19:10 +03:00
parent 6925ed9b33
commit 4fb78bbcd9
17 changed files with 232 additions and 70 deletions

View File

@@ -56,23 +56,33 @@ func NewReporter() *Reporter {
// AddErr adds an error to the error stack.
// if "err" is a StackError then
// each of these errors will be printed as individual.
func (r *Reporter) AddErr(err error) {
//
// Returns true if this "err" is not nil and it's added to the reporter's stack.
func (r *Reporter) AddErr(err error) bool {
if err == nil {
return
return false
}
if stackErr, ok := err.(StackError); ok {
r.addStack(stackErr.Stack())
return
} else {
r.mu.Lock()
r.wrapper = r.wrapper.AppendErr(err)
r.mu.Unlock()
}
r.mu.Lock()
r.wrapper = r.wrapper.AppendErr(err)
r.mu.Unlock()
return true
}
// Add adds a formatted message as an error to the error stack.
func (r *Reporter) Add(format string, a ...interface{}) {
//
// Returns true if this "err" is not nil and it's added to the reporter's stack.
func (r *Reporter) Add(format string, a ...interface{}) bool {
if format == "" && len(a) == 0 {
return false
}
// usually used as: "module: %v", err so
// check if the first argument is error and if that error is empty then don't add it.
if len(a) > 0 {
@@ -81,7 +91,7 @@ func (r *Reporter) Add(format string, a ...interface{}) {
Error() string
}); ok {
if e.Error() == "" {
return
return false
}
}
}
@@ -89,6 +99,7 @@ func (r *Reporter) Add(format string, a ...interface{}) {
r.mu.Lock()
r.wrapper = r.wrapper.Append(format, a...)
r.mu.Unlock()
return true
}
// Describe same as `Add` but if "err" is nil then it does nothing.

View File

@@ -545,12 +545,6 @@ func (api *APIBuilder) Controller(relativePath string, controller activator.Base
api.reporter.Add("%v for path: '%s'", err, relativePath)
}
if cInit, ok := controller.(interface {
Init(activator.RegisterFunc)
}); ok {
cInit.Init(registerFunc)
}
return
}