fixed error handling of db method