lib/fluent/plugin/out_http.rb in fluent-plugin-out-http-0.1.2 vs lib/fluent/plugin/out_http.rb in fluent-plugin-out-http-0.1.3

- old
+ new

@@ -19,10 +19,13 @@ # Simple rate limiting: ignore any records within `rate_limit_msec` # since the last one. config_param :rate_limit_msec, :integer, :default => 0 + # Raise errors that were rescued during HTTP requests? + config_param :raise_on_error, :bool, :default => true + # nil | 'none' | 'basic' config_param :authentication, :string, :default => nil config_param :username, :string, :default => '' config_param :password, :string, :default => '' @@ -102,12 +105,13 @@ if @auth and @auth == :basic req.basic_auth(@username, @password) end @last_request_time = Time.now.to_f res = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) } - rescue # rescue all StandardErrors + rescue => e # rescue all StandardErrors # server didn't respond - $log.warn "Net::HTTP.#{req.method.capitalize} raises exception: #{$!.class}, '#{$!.message}'" + $log.warn "Net::HTTP.#{req.method.capitalize} raises exception: #{e.class}, '#{e.message}'" + raise e if @raise_on_error else unless res and res.is_a?(Net::HTTPSuccess) res_summary = if res "#{res.code} #{res.message} #{res.body}" else