
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
None | size: 0.88 KB | hits: 15 | expires: Never
# Monkey patch exception logging into async_sinatra
#
# This is a workaround for the lack of error handling/logging on asynchronous
# requests (e.g. aget, apost) when using async_sinatra 0.5.0, sinatra 1.2.6,
# thin 1.2.11, and rack 1.3.0.
#
# See http://stackoverflow.com/questions/6427033/how-do-i-log-asynchronous-thinsinatrarack-requests
module Sinatra::Async
alias :oldaroute :aroute
def aroute *args, &block
oldaroute(*args) { |*a|
begin
block.call *a
rescue Exception => e
status 500
puts "Asynchronous exception:"
puts "#{e.class} - #{e.message}: \n #{e.backtrace.join("\n ")}\n"
ahalt e
end
}
end
end