Skip to content

Commit

Permalink
handle error
Browse files Browse the repository at this point in the history
  • Loading branch information
sh-ikeda committed Jan 10, 2024
1 parent 8394e6f commit 0b68ab0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions bin/sparql_taxon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@

File.read(taxonomy_list).split("\n").each do |taxon|
i = 0
loop_count = 0
while i % limit == 0
if loop_count * limit != i
$stderr.puts "Error: Failed to retrieve taxon:#{taxon} in loop_count:#{loop_count}"
break
end
query = query_template.sub('{{taxon}}', taxon) + " OFFSET #{i} LIMIT #{limit}"
cmd = "curl -s -H 'Accept: text/csv' --data-urlencode 'query=#{query}' #{endpoint} | sed -E 1d"
IO.popen(cmd) do |io|
Expand All @@ -18,5 +23,6 @@
i += 1
end
end
loop_count += 1
end
end

0 comments on commit 0b68ab0

Please sign in to comment.