diff --git a/persistence/sql/persister_oauth2.go b/persistence/sql/persister_oauth2.go index 1a1803597a8..e187ea230ef 100644 --- a/persistence/sql/persister_oauth2.go +++ b/persistence/sql/persister_oauth2.go @@ -378,7 +378,9 @@ func (p *Persister) FlushInactiveAccessTokens(ctx context.Context, notAfter time notAfter, ) if err := q.All(&signatures); err == sql.ErrNoRows { - return errors.Wrap(fosite.ErrNotFound, "") + return errorsx.WithStack(fosite.ErrNotFound) + } else if err != nil { + return errorsx.WithStack(err) } // Delete tokens in batch @@ -416,7 +418,9 @@ func (p *Persister) FlushInactiveRefreshTokens(ctx context.Context, notAfter tim notAfter, ) if err := q.All(&signatures); err == sql.ErrNoRows { - return errors.Wrap(fosite.ErrNotFound, "") + return errorsx.WithStack(fosite.ErrNotFound) + } else if err != nil { + return errorsx.WithStack(err) } // Delete tokens in batch