From b1c78dce284b1f1bf21189b86d28c29e17f07a48 Mon Sep 17 00:00:00 2001 From: Asai Neko Date: Wed, 21 Jan 2026 14:28:23 +0800 Subject: [PATCH] Add Build error hook (print exception) Signed-off-by: Asai Neko --- internal/exception/builder.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/exception/builder.go b/internal/exception/builder.go index a434344..349d7b0 100644 --- a/internal/exception/builder.go +++ b/internal/exception/builder.go @@ -2,6 +2,7 @@ package exception import ( "fmt" + "log/slog" ) // 12 chars len @@ -17,6 +18,7 @@ type Builder struct { Endpoint string Type string Original string + Error error } func (self *Builder) SetStatus(s string) *Builder { @@ -44,12 +46,21 @@ func (self *Builder) SetOriginal(s string) *Builder { return self } +func (self *Builder) SetError(e error) *Builder { + self.Error = e + return self +} + func (self *Builder) Build() string { - return fmt.Sprintf("%s%s%s%s%s", + errorCode := fmt.Sprintf("%s%s%s%s%s", self.Status, self.Service, self.Endpoint, self.Type, self.Original, ) + if self.Error != nil { + slog.Warn("Service exception", "id", errorCode, "err", self.Error) + } + return errorCode }