better error handling during acquiring resources