mod/user: add check for when usr is not found
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
leo 2023-05-03 06:08:28 +02:00
parent ce70bbe196
commit faefe3b577
Signed by: wanderer
SSH Key Fingerprint: SHA256:Dp8+iwKHSlrMEHzE3bJnPng70I7LEsa3IJXRH/U+idQ

View File

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