Error detection added to add_deploy_key function