sferencik
sferencik

Reputation: 3249

Ruby rescue and abort

I am seeing this pattern in someone else's Rakefile:

begin
  sh "..."
rescue
  abort
end

What's the author doing here? Why rescue if I'm going to abort anyway? Do I understand correctly that this mutes the potential shell error?

I am new to ruby and rake. As far as I understand, the sh is rake's shorthand for FileUtils.sh() (ref). And FileUtils.sh() may raise a RuntimeError (ref).

Does this mean that we are effectively throwing away the information/message in the RuntimeError and exiting rake with an error status, but without a specific error message? Is this a rake/ruby pattern? Any recommended reading?

Upvotes: 1

Views: 342

Answers (0)

Related Questions