error handling for both db and normal errors2