From d38fa60fbc24699561fc1e02fb779036aed2c4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sun, 7 Jan 2024 04:01:13 +0100 Subject: [PATCH] v0.0.361 call exerrListener in ginext.Error --- exerr/builder.go | 8 ++++---- exerr/listener.go | 6 ++---- ginext/response.go | 2 ++ goextVersion.go | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/exerr/builder.go b/exerr/builder.go index 264d382..3dcc651 100644 --- a/exerr/builder.go +++ b/exerr/builder.go @@ -420,7 +420,7 @@ func (b *Builder) Build() error { b.errorData.ShortLog(stackSkipLogger.Error()) } - b.CallListener(MethodBuild) + b.errorData.CallListener(MethodBuild) return b.errorData } @@ -442,7 +442,7 @@ func (b *Builder) Output(ctx context.Context, g *gin.Context) { b.errorData.Log(stackSkipLogger.Warn()) } - b.CallListener(MethodOutput) + b.errorData.CallListener(MethodOutput) } // Print prints the error @@ -454,7 +454,7 @@ func (b *Builder) Print() { b.errorData.ShortLog(stackSkipLogger.Warn()) } - b.CallListener(MethodPrint) + b.errorData.CallListener(MethodPrint) } func (b *Builder) Format(level LogPrintLevel) string { @@ -467,7 +467,7 @@ func (b *Builder) Fatal() { b.errorData.Severity = SevFatal b.errorData.Log(stackSkipLogger.WithLevel(zerolog.FatalLevel)) - b.CallListener(MethodFatal) + b.errorData.CallListener(MethodFatal) os.Exit(1) } diff --git a/exerr/listener.go b/exerr/listener.go index e890977..8cd4002 100644 --- a/exerr/listener.go +++ b/exerr/listener.go @@ -25,13 +25,11 @@ func RegisterListener(l Listener) { listener = append(listener, l) } -func (b *Builder) CallListener(m Method) { - valErr := b.errorData - +func (ee *ExErr) CallListener(m Method) { listenerLock.Lock() defer listenerLock.Unlock() for _, v := range listener { - v(m, valErr) + v(m, ee) } } diff --git a/ginext/response.go b/ginext/response.go index dc71d7d..c80a322 100644 --- a/ginext/response.go +++ b/ginext/response.go @@ -328,6 +328,8 @@ type jsonAPIErrResponse struct { func (j jsonAPIErrResponse) Write(g *gin.Context) { j.err.Output(g) + + j.err.CallListener(exerr.MethodOutput) } func (j jsonAPIErrResponse) WithHeader(k string, v string) HTTPResponse { diff --git a/goextVersion.go b/goextVersion.go index 2912da9..545c3fe 100644 --- a/goextVersion.go +++ b/goextVersion.go @@ -1,5 +1,5 @@ package goext -const GoextVersion = "0.0.360" +const GoextVersion = "0.0.361" -const GoextVersionTimestamp = "2024-01-06T01:31:07+0100" +const GoextVersionTimestamp = "2024-01-07T04:01:12+0100"