Skip to content

Commit

Permalink
We want to move some of the work to methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurtis Rainbolt-Greene committed Apr 28, 2015
1 parent e06ded8 commit 058aec8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/whiskey/server.rb
Expand Up @@ -61,19 +61,13 @@ def run

def process(handler)
Whiskey.logger.info("New connection created from #{handler.id}")
begin
handler.process
rescue => error
Whiskey.logger.error(error)
ensure
# If the connection has been broken, this might not work: Errno::EPIPE
begin
handler.write(serialized_internal_server_error)
rescue => error
Whiskey.logger.error(error)
end
handler.close
end
handler.process
rescue => error
Whiskey.logger.error(error)
ensure
# If the connection has been broken, this might not work: Errno::EPIPE
write_server_error
handler.close
end

def serialized_internal_server_error
Expand All @@ -91,6 +85,12 @@ def handle(connection)
def connection_with(server)
Connection.new(server.accept)
end

def write_server_error
handler.write(serialized_internal_server_error)
rescue => error
Whiskey.logger.error(error)
end
end
end

Expand Down

0 comments on commit 058aec8

Please sign in to comment.