api - Ruby rescue syntax error -
i have following line of code giving me error:
rescue timeout::error => e logs.puts("rescued timeout error...#{e}") email_ids_all.each |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
the error receiving this:
syntax error, unexpected keyword_rescue, expecting $end rescue timeout::error => e ^
essentially trying run api delete call if script times out. doesn't seem matter put in block rescue
though, receive same error. what's wrong syntax on rescue
method?
the format using rescue
follows:
begin # code want run might raise exceptions rescue yourexceptionclass => e # code runs in case of yourexceptionclass rescue adifferenterror => e # code runs in case of adifferenterror else # code runs if there no error ensure # code runs @ end regardless of whether or not there error end
here question lots more information: begin, rescue , ensure in ruby?.
Comments
Post a Comment