goext/exerr/listener.go
Mike Schwörer ce7837b9ef
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m39s
v0.0.455 add proper json/bson marshalling to exerr [severity|type|category]
2024-05-16 15:38:42 +02:00

27 lines
411 B
Go

package exerr
import (
"sync"
)
type Listener = func(method Method, v *ExErr)
var listenerLock = sync.Mutex{}
var listener = make([]Listener, 0)
func RegisterListener(l Listener) {
listenerLock.Lock()
defer listenerLock.Unlock()
listener = append(listener, l)
}
func (ee *ExErr) CallListener(m Method) {
listenerLock.Lock()
defer listenerLock.Unlock()
for _, v := range listener {
v(m, ee)
}
}