Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Catch RuntimeError when parsing #65

Merged
merged 1 commit into from
Dec 30, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions lib/cc/engine/analyzers/analyzer_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,22 @@ class Base
::Errno::ENOENT,
::Racc::ParseError,
::RubyParser::SyntaxError,
]
::RuntimeError,
].freeze

def initialize(engine_config:)
@engine_config = engine_config
end

def run(file)
process_file(file)
rescue *RESCUABLE_ERRORS => ex
$stderr.puts("Skipping file #{file} due to exception (#{ex.class}): #{ex.message}\n#{ex.backtrace.join("\n")}")
rescue => ex
$stderr.puts("#{ex.class} error occurred processing file #{file}: aborting.")
raise ex
if RESCUABLE_ERRORS.map { |klass| ex.instance_of?(klass) }.include?(true)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before anybody asks: ActiveSupport is not included in this gem, and it doesn't seem worth adding just for this.

$stderr.puts("Skipping file #{file} due to exception (#{ex.class}): #{ex.message}\n#{ex.backtrace.join("\n")}")
else
$stderr.puts("#{ex.class} error occurred processing file #{file}: aborting.")
raise ex
end
end

def files
Expand Down