lib/scalyr/common/client.rb in logstash-output-scalyr-0.2.7.beta vs lib/scalyr/common/client.rb in logstash-output-scalyr-0.2.8.beta
- old
+ new
@@ -25,13 +25,25 @@
#---------------------------------------------------------------------------------------------------------------------
# An exception that signifies the Scalyr server received the upload request but dropped it
#---------------------------------------------------------------------------------------------------------------------
class RequestDroppedError < ServerError;
+ def initialize(msg=nil, code=nil, url=nil, body=nil, e_class="Scalyr::Common::Client::RequestDroppedError")
+ super(msg, code, url, body, e_class)
+ end
end
#---------------------------------------------------------------------------------------------------------------------
+# An exception that signifies the Scalyr server received the upload request but dropped it due to it being too large.
+#---------------------------------------------------------------------------------------------------------------------
+class PayloadTooLargeError < ServerError;
+ def initialize(msg=nil, code=nil, url=nil, body=nil, e_class="Scalyr::Common::Client::PayloadTooLargeError")
+ super(msg, code, url, body, e_class)
+ end
+end
+
+#---------------------------------------------------------------------------------------------------------------------
# An exception representing failure of the http client to upload data to Scalyr (in contrast to server-side errors
# where the POST api succeeds, but the Scalyr server then responds with an error)
#---------------------------------------------------------------------------------------------------------------------
class ClientError < StandardError
@@ -306,18 +318,20 @@
@logger.debug "JSON response does not contain status message"
raise ServerError.new "JSON response does not contain status message"
end
status = response_hash["status"]
+ code = response.code.to_s.strip.to_i
if status != "success"
- if status =~ /discardBuffer/
+ if code == 413
+ raise PayloadTooLargeError.new(status, response.code, @add_events_uri, response.body)
+ elsif status =~ /discardBuffer/
raise RequestDroppedError.new(status, response.code, @add_events_uri, response.body)
else
raise ServerError.new(status, response.code, @add_events_uri, response.body)
end
else
- code = response.code.to_s.strip.to_i
if code < 200 or code > 299
raise ServerError.new(status, response.code, @add_events_uri, response.body)
end
end