def handle_exceptions(response)
            begin
                yield
            rescue => error
                message = "Exception: #{error}"
                message << "\n#{error.backtrace.join("\n")}" \
                    if (error.respond_to?(:backtrace))
                Server.logger.error(message)
                return if response.isCommitted
                response.reset
                response.setStatus(500)
            end
        end
def handle_exceptions(response)
            begin
                yield
            rescue => error
                message = "Exception: #{error}"
                message << "\n#{error.backtrace.join("\n")}" \
                    if (error.respond_to?(:backtrace))
                Server.logger.error(message)
                return if response.isCommitted
                response.reset
                response.setStatus(500)
            end
        end
Handle exceptions, returning a generic 500 error response.