Add ErrorHandler for log level selects

Signed-off-by: Asai Neko <sugar@sne.moe>
This commit is contained in:
2026-01-21 15:48:49 +08:00
parent 75c4edfa3d
commit 7b3fe24b7c
2 changed files with 17 additions and 2 deletions

View File

@@ -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)
}
}