lib/moysklad/client/errors.rb in moysklad-0.0.2 vs lib/moysklad/client/errors.rb in moysklad-0.1.1

- old
+ new

@@ -1,19 +1,21 @@ class Moysklad::Client class Errors - def self.build + def self.build res Moysklad.logger.warn "Moyskad::Client: #{res.status}: #{res.env.url.to_s}\n#{res.body}" case res.status when 405 raise MethodNotAllowedError.new res when 401 raise UnauthorizedError.new res when 404 raise NoResourceFound.new res.body - when 500 + when 500 raise ParsedError.new(res) + when 502 + raise HtmlParsedError.new(res) else raise ParsedError.new(res) end end end @@ -34,11 +36,11 @@ class NoResourceFound < Error; end class HtmlParsedError < Error def initialize res - @result = res - @message = parse_title res.body + @result = res + @message = "[#{res.status}] #{parse_title res.body}" end private def parse_title body