Skip to content

Commit

Permalink
Merge pull request #1198 from skalee/fix-exception-handling
Browse files Browse the repository at this point in the history
Fix rescue clause
  • Loading branch information
lsegal committed Jan 23, 2019
2 parents d84d589 + cea13da commit 65b152b
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 65b152b

Please sign in to comment.