If you have two Net::SFTP::Exceptions in one process, the error messages get concatenated. This is probably because the message method of RuntimError (or of something above) returns something static which gets reset only in the initialize method:
class MyError < RuntimeError
def initialize(response)
@response = response
end
def message
m = super
m << @response
end
end
2.times do
begin
raise MyError.new('error')
rescue RuntimeError => e
puts e.message
end
end
Which outputs:
MyErrorerror
MyErrorerrorerror
If you call super from the initialize method or change the last line in the message method to “m + @response” the outputs are more as expected:
MyErrorerror
MyErrorerror
errorerror
errorerror