lib/iconoclasm/errors.rb in iconoclasm-1.0.0 vs lib/iconoclasm/errors.rb in iconoclasm-1.0.1

- old
+ new

@@ -28,15 +28,23 @@ def code @response.respond_to?(:response_code) ? @response.response_code : @response[/\d{3}/] end def http_error_reason - @response.respond_to?(:header_str) ? @response.header_str[/(?<=\d{3}\s)(.*)$/].chomp : @response - end + @response.respond_to?(:header_str) ? error_reason : @response + end def http_error_message "#{@code}: #{http_error_reason}" - end + end + + private + + def error_reason + first_line = @response.header_str.split('\n').first.chomp + first_line.match(/\d{3}\s(.*)$/) + $1 + end end class RTFMError < Iconoclasm::Error def initialize(reason) @reason = reason \ No newline at end of file