Unify checkDBError implementation