Files
cms-server/internal/exception/error.go
2026-01-24 11:42:35 +08:00

20 lines
619 B
Go

package exception
import (
"context"
"log/slog"
)
func ErrorHandler(ctx *context.Context, status string, errorCode string, err error) {
switch status {
case StatusSuccess:
slog.InfoContext(*ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err)
case StatusUser:
slog.WarnContext(*ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err)
case StatusServer:
slog.ErrorContext(*ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err)
case StatusClient:
slog.ErrorContext(*ctx, "Service exception! ErrId: "+errorCode, "id", errorCode, "err", err)
}
}