Skip to content

Commit

Permalink
Fix rescue clause
Browse files Browse the repository at this point in the history
In case of ArgumentError unrelated to encoding, it used to enter an
infinite loop.
  • Loading branch information
skalee committed Oct 6, 2018
1 parent 3ffb577 commit cea13da
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/yard/code_objects/extra_file_object.rb
Expand Up @@ -113,14 +113,17 @@ def parse_contents(data)
end
contents
rescue ArgumentError => e
if retried && e.message =~ /invalid byte sequence/
raise unless e.message =~ /invalid byte sequence/

if retried
# This should never happen.
log.warn "Could not read #{filename}, #{e.message}. You probably want to set `--charset`."
return ''
else
data.force_encoding('binary') if data.respond_to?(:force_encoding)
retried = true
retry
end
data.force_encoding('binary') if data.respond_to?(:force_encoding)
retried = true
retry
end

def translate(data)
Expand Down

0 comments on commit cea13da

Please sign in to comment.