Skip to content

Commit

Permalink
fix: fixed error handling in persister
Browse files Browse the repository at this point in the history
  • Loading branch information
mitar committed Nov 16, 2021
1 parent ef11adf commit 8760dff
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions persistence/sql/persister_oauth2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -394,6 +396,9 @@ func (p *Persister) FlushInactiveAccessTokens(ctx context.Context, notAfter time
fmt.Sprintf("DELETE FROM %s WHERE signature in (?)", OAuth2RequestSQL{Table: sqlTableAccess}.TableName()),
signatures[i:j],
).Exec()
if err != nil {
break
}
}
}
return sqlcon.HandleError(err)
Expand All @@ -416,7 +421,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
Expand All @@ -432,6 +439,9 @@ func (p *Persister) FlushInactiveRefreshTokens(ctx context.Context, notAfter tim
fmt.Sprintf("DELETE FROM %s WHERE signature in (?)", OAuth2RequestSQL{Table: sqlTableRefresh}.TableName()),
signatures[i:j],
).Exec()
if err != nil {
break
}
}
}
return sqlcon.HandleError(err)
Expand Down

0 comments on commit 8760dff

Please sign in to comment.