lib/wordnik/response.rb in wordnik-4.06.13 vs lib/wordnik/response.rb in wordnik-4.06.14
- old
+ new
@@ -13,24 +13,21 @@
validates_presence_of :raw
def initialize(raw)
self.raw = raw
+ catch_errors
+ end
- case self.code
- when 500..510 then raise(ServerError, self.error_message)
- when 299..426 then raise(ClientError, self.error_message)
- end
- end
-
def code
raw.code
end
-
- def error_message
- body['message']
- rescue
- body
+
+ def catch_errors
+ case self.code
+ when 500..510 then raise(ServerError, self.raw.to_yaml)
+ when 299..426 then raise(ClientError, self.raw.to_yaml)
+ end
end
# If body is JSON, parse it
# TODO: If body is XML, parse it
# Otherwise return raw string
\ No newline at end of file