我有以下代码行给我一个错误:
rescue Timeout::Error => e
logs.puts("Rescued a timeout error...#{e}")
email_ids_all.each do |email_delete|
call= "/api/v2/emails/#{email_delete}/"
uri= HTTParty.delete("https://www.surveys.com#{call}",
:basic_auth => auth,
:headers => { 'ContentType' => 'application/x-www-form-urlencoded', 'Content-Length' => "0" }
)
puts "Deleted email #{email_delete}".green
log.puts("Deleted email #{email_delete}")
end
abort #abort entire script after deleting emails
end
我收到的错误是这样的:
syntax error, unexpected keyword_rescue, expecting $end
rescue Timeout::Error => e
^
本质上,如果脚本超时,我只是尝试运行 API 删除调用。不过,我放入块中的内容似乎并不重要rescue
,我收到了同样的错误。我的rescue
方法语法有什么问题?