diff --git a/internal/exception/builder.go b/internal/exception/builder.go index 349d7b0..ff45eb8 100644 --- a/internal/exception/builder.go +++ b/internal/exception/builder.go @@ -2,7 +2,6 @@ package exception import ( "fmt" - "log/slog" ) // 12 chars len @@ -60,7 +59,7 @@ func (self *Builder) Build() string { self.Original, ) if self.Error != nil { - slog.Warn("Service exception", "id", errorCode, "err", self.Error) + ErrorHandler(self.Status, errorCode, self.Error) } return errorCode } diff --git a/internal/exception/error.go b/internal/exception/error.go new file mode 100644 index 0000000..06a3c7a --- /dev/null +++ b/internal/exception/error.go @@ -0,0 +1,16 @@ +package exception + +import "log/slog" + +func ErrorHandler(status string, errorCode string, err error) { + switch status { + case StatusSuccess: + slog.Info("Service exception", "id", errorCode, "err", err) + case StatusUser: + slog.Warn("Service exception", "id", errorCode, "err", err) + case StatusServer: + slog.Error("Service exception", "id", errorCode, "err", err) + case StatusClient: + slog.Error("Service exception", "id", errorCode, "err", err) + } +}