From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.248.11 with SMTP id me11cs52219qcb; Fri, 8 Oct 2010 13:58:24 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCNSYpqGTFhDri77lBBoEY91l9g@googlegroups.com designates 10.142.248.2 as permitted sender) client-ip=10.142.248.2; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCNSYpqGTFhDri77lBBoEY91l9g@googlegroups.com designates 10.142.248.2 as permitted sender) smtp.mail=rack-devel+bncCNSYpqGTFhDri77lBBoEY91l9g@googlegroups.com; dkim=pass header.i=rack-devel+bncCNSYpqGTFhDri77lBBoEY91l9g@googlegroups.com Received: from mr.google.com ([10.142.248.2]) by 10.142.248.2 with SMTP id v2mr707956wfh.45.1286571501897 (num_hops = 1); Fri, 08 Oct 2010 13:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:date:from:to:subject:message-id :mime-version:user-agent:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type:content-disposition; bh=5Vzz3BZdjFt0TX91DqvQVLuFWFgUfdKmYNti79ZHd1U=; b=6OkFuFTIaYa73siknGTeDoos0BsT1yOKkN4d4AIXZVJzjQMdAf0yCrZ6ZANJsBnPOO lbvMmZPTwsWpmluTOzyrTQ7sgFaj5Z2uTHqzjJOssOyWUuUzZxtqQ74elqTmlDLspJLq MZsS8ZSLmkjd019QZ4vfRg9ZzQsL6/IjlLOvM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:date:from:to:subject:message-id :mime-version:user-agent:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type:content-disposition; b=t7LHH3OrDo5iu9hN5qxgPVgYGVheYo49a0hr3MkT71sXooksTtvJbu1j5UeWOYhOx2 NwsWgMBajj8dZASDkYiNDCbR5lbZjtztduKSO59bZP1pwvUHJN5WOuZuxlW2zBVWZHzA 1PaygOAYdX41qrXXxHwGx2CStBJlDsWV7TVII= Received: by 10.142.248.2 with SMTP id v2mr131467wfh.45.1286571499577; Fri, 08 Oct 2010 13:58:19 -0700 (PDT) X-BeenThere: rack-devel@googlegroups.com Received: by 10.142.194.14 with SMTP id r14ls692120wff.2.p; Fri, 08 Oct 2010 13:58:18 -0700 (PDT) Received: by 10.143.9.17 with SMTP id m17mr703064wfi.43.1286571498769; Fri, 08 Oct 2010 13:58:18 -0700 (PDT) Received: by 10.143.9.17 with SMTP id m17mr703063wfi.43.1286571498738; Fri, 08 Oct 2010 13:58:18 -0700 (PDT) Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by gmr-mx.google.com with ESMTP id s21si1104227wff.0.2010.10.08.13.58.18; Fri, 08 Oct 2010 13:58:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of normalperson@yhbt.net designates 64.71.152.64 as permitted sender) client-ip=64.71.152.64; Received: from localhost (unknown [127.0.2.5]) by dcvr.yhbt.net (Postfix) with ESMTP id 4BF241F500; Fri, 8 Oct 2010 20:58:18 +0000 (UTC) Date: Fri, 8 Oct 2010 13:58:18 -0700 From: Eric Wong To: rack-devel@googlegroups.com Subject: [PATCH] showexceptions: gracefully handle empty backtraces Message-ID: <20101008205818.GA28043@dcvr.yhbt.net> MIME-Version: 1.0 User-Agent: Mutt/1.5.18 (2008-05-17) X-Original-Sender: normalperson@yhbt.net X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of normalperson@yhbt.net designates 64.71.152.64 as permitted sender) smtp.mail=normalperson@yhbt.net Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Also pushed out to the "showexceptions" branch of git://git.bogomips.org/rack.git http://git.bogomips.org/cgit/rack.git/commit/?id=bfb59e0f92271f8ecb60e5b7146c1b6e656938b8 >From bfb59e0f92271f8ecb60e5b7146c1b6e656938b8 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 8 Oct 2010 12:04:24 -0700 Subject: [PATCH] showexceptions: gracefully handle empty backtraces Some HTTP servers (e.g. Unicorn and Rainbows!) raise certain exceptions without a backtrace[1], so avoid triggering our own NoMethodError exception because of this. [1] - http://git.bogomips.org/cgit/unicorn.git/commit/?id=e4256da292f9626d7dfca60e08f65651a0a9139a --- lib/rack/showexceptions.rb | 8 +++++++- test/spec_showexceptions.rb | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletions(-) diff --git a/lib/rack/showexceptions.rb b/lib/rack/showexceptions.rb index 697bc41..26ff923 100644 --- a/lib/rack/showexceptions.rb +++ b/lib/rack/showexceptions.rb @@ -195,7 +195,13 @@ TEMPLATE = <<'HTML'

<%=h exception.message %>

- + diff --git a/test/spec_showexceptions.rb b/test/spec_showexceptions.rb index 82ac918..908f7b7 100644 --- a/test/spec_showexceptions.rb +++ b/test/spec_showexceptions.rb @@ -20,4 +20,24 @@ describe Rack::ShowExceptions do res.should =~ /RuntimeError/ res.should =~ /ShowExceptions/ end + + it "handles exceptions without a backtrace" do + res = nil + + req = Rack::MockRequest.new( + Rack::ShowExceptions.new( + lambda{|env| raise RuntimeError, "", [] } + )) + + lambda{ + res = req.get("/") + }.should.not.raise + + res.should.be.a.server_error + res.status.should.equal 500 + + res.should =~ /RuntimeError/ + res.should =~ /ShowExceptions/ + res.should =~ /unknown location/ + end end -- Eric Wong
Ruby<%=h frames.first.filename %>: in <%=h frames.first.function %>, line <%=h frames.first.lineno %> +<% if first = frames.first %> + <%=h first.filename %>: in <%=h first.function %>, line <%=h frames.first.lineno %> +<% else %> + unknown location +<% end %> +
Web <%=h req.request_method %> <%=h(req.host + path)%>