Handle db errors