All checks were successful
Server Check Build (NixCN CMS) TeamCity build finished
Signed-off-by: Asai Neko <sugar@sne.moe>
20 lines
766 B
Go
20 lines
766 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!, ErrorCode: "+errorCode, slog.String("error_code", errorCode), slog.Any("error", err))
|
|
case StatusUser:
|
|
slog.WarnContext(ctx, "Service exception!, ErrorCode: "+errorCode, slog.String("error_code", errorCode), slog.Any("error", err))
|
|
case StatusServer:
|
|
slog.ErrorContext(ctx, "Service exception!, ErrorCode: "+errorCode, slog.String("error_code", errorCode), slog.Any("error", err))
|
|
case StatusClient:
|
|
slog.ErrorContext(ctx, "Service exception!, ErrorCode: "+errorCode, slog.String("error_code", errorCode), slog.Any("error", err))
|
|
}
|
|
}
|