Fixed a bug in db error handler