InreplaceError: fix undefined method crash

When the first parameter to inreplace was an array, and the replacement
failed, InreplaceError would end up crashing with an undefined method
exception because the order of operations resulted in super not being
passed the value of the entire inject block.
This commit is contained in:
ilovezfs 2017-01-12 07:22:34 -08:00
parent ebf3d939d1
commit ac7a593730

View File

@ -1,9 +1,10 @@
module Utils
class InreplaceError < RuntimeError
def initialize(errors)
super errors.inject("inreplace failed\n") do |s, (path, errs)|
formatted_errors = errors.inject("inreplace failed\n") do |s, (path, errs)|
s << "#{path}:\n" << errs.map { |e| " #{e}\n" }.join
end
super formatted_errors
end
end