From faefe3b577e961eca9bb25282764a76c8eb5e4fd Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 3 May 2023 06:08:28 +0200 Subject: [PATCH] mod/user: add check for when usr is not found --- modules/user/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/user/user.go b/modules/user/user.go index fe3d037..1c3034f 100644 --- a/modules/user/user.go +++ b/modules/user/user.go @@ -53,6 +53,12 @@ func QueryUser(ctx context.Context, client *ent.Client, username string) (*ent.U // or more than 1 user returned. Only(ctx) if err != nil { + log.Warn("error querying user", "error", err, "username requested", username) + + if ent.IsNotFound(err) { + return nil, fmt.Errorf("user not found: %q", err) + } + return nil, fmt.Errorf("failed querying user: %w", err) }