handle db errors gracefully