Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rescue clause #1198

Merged
merged 1 commit into from Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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