fix: make discord login work if no user exists
This commit is contained in:
parent
8c187d0fb3
commit
75f628c722
|
@ -102,6 +102,10 @@ func (db *DB) DiscordUser(ctx context.Context, discordID string) (u User, err er
|
|||
var id xid.ID
|
||||
err = db.QueryRow(ctx, sql, args...).Scan(&id)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == pgx.ErrNoRows {
|
||||
return u, ErrUserNotFound
|
||||
}
|
||||
|
||||
return u, errors.Wrap(err, "executing id query")
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,14 @@ type APIError struct {
|
|||
}
|
||||
|
||||
func (e APIError) Error() string {
|
||||
if e.Message == "" {
|
||||
e.Message = errCodeMessages[e.Code]
|
||||
}
|
||||
|
||||
if e.Details != "" {
|
||||
return fmt.Sprintf("%s (code: %d) (%s)", e.Message, e.Code, e.Details)
|
||||
}
|
||||
|
||||
return fmt.Sprintf("%s (code: %d)", e.Message, e.Code)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue