Before Ruby 2.5, if we want to log a caught exception, we would need to format it ourselves. 1class AverageService 2 attr_reader :numbers, :coerced_numbers 3 4 def initialize(numbers) 5 @numbers = numbers 6 @coerced_numbers = coerce_numbers 7 end 8 9 def average 10 sum / count 11 end 12 13 private 14 15 def coerce_numbers 16 numbers.map do |number| 17 begin 18 Float(number) 19 rescue Exception =>
![Ruby 2.5 adds Exception#full_message method](https://cdn-ak-scissors.b.st-hatena.com/image/square/df7dcf3e382d2d4b018ba79fc6642260e3fa7070/height=288;version=1;width=512/https%3A%2F%2Fres.cloudinary.com%2Fdpc4i4bdx%2Fimage%2Fupload%2Fbigbinary_blogs%2Fdefault_blog_image.png)