Sha256: da348f925cea5f44ab9604fafd39f7567519da3038a3839bfdd9d79d2256ed5b

Contents?: true

Size: 1.07 KB

Versions: 8

Compression:

Stored size: 1.07 KB

Contents

# -*- encoding: binary -*-
# :enddoc:
module Rainbows::Error

  # if we get any error, try to write something back to the client
  # assuming we haven't closed the socket, but don't get hung up
  # if the socket is already closed or broken.  We'll always ensure
  # the socket is closed at the end of this function
  def self.write(io, e)
    msg = response(e) and Kgio.trywrite(io, msg)
    rescue
  end

  def self.app(e)
    Unicorn.log_error(Rainbows.server.logger, "app error", e)
    rescue
  end

  def self.listen_loop(e)
    Rainbows.alive or return
    Unicorn.log_error(Rainbows.server.logger, "listen loop error", e)
    rescue
  end

  def self.response(e)
    case e
    when EOFError, Errno::ECONNRESET, Errno::EPIPE, Errno::EINVAL,
         Errno::EBADF, Errno::ENOTCONN
      # swallow error if client shuts down one end or disconnects
    when Unicorn::HttpParserError
      Rainbows::Const::ERROR_400_RESPONSE # try to tell the client they're bad
    when IOError # HttpParserError is an IOError
    else
      app(e)
      Rainbows::Const::ERROR_500_RESPONSE
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
rainbows-4.5.0 lib/rainbows/error.rb
rainbows-4.4.3 lib/rainbows/error.rb
rainbows-4.4.2 lib/rainbows/error.rb
rainbows-4.4.1.1.gd5c8c lib/rainbows/error.rb
rainbows-4.4.1 lib/rainbows/error.rb
rainbows-4.4.0 lib/rainbows/error.rb
rainbows-4.3.1 lib/rainbows/error.rb
rainbows-4.3.0 lib/rainbows/error.rb