From 35433792f9fa23f7b8d9c771d1d3676286a48870 Mon Sep 17 00:00:00 2001 From: Azul Date: Fri, 23 Sep 2016 15:54:56 +0200 Subject: basic logging and recovery from exceptions raised --- lib/nickserver/reel_server.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'lib/nickserver/reel_server.rb') diff --git a/lib/nickserver/reel_server.rb b/lib/nickserver/reel_server.rb index d2a95ba..9a7053b 100644 --- a/lib/nickserver/reel_server.rb +++ b/lib/nickserver/reel_server.rb @@ -23,14 +23,24 @@ module Nickserver def on_connection(connection) connection.each_request do |request| - handler = handler_for(request) - handler.respond_to params(request), request.headers + handle_request(request) end end protected + def handle_request(request) + puts "#{request.method} #{request.uri}" + puts " #{params(request)}" + handler = handler_for(request) + handler.respond_to params(request), request.headers + rescue StandardError => e + puts e + puts e.backtrace.join "\n " + request.respond 500, "{}" + end + def handler_for(request) # with reel the request is the responder Dispatcher.new(request) -- cgit v1.2.3