Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4D19E9985 for ; Tue, 28 Feb 2012 16:11:41 +0000 (UTC) Received: (qmail 18025 invoked by uid 500); 28 Feb 2012 16:11:41 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 18007 invoked by uid 500); 28 Feb 2012 16:11:41 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 17999 invoked by uid 99); 28 Feb 2012 16:11:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2012 16:11:41 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of marios@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Feb 2012 16:11:34 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q1SGBE0T020663 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Feb 2012 11:11:14 -0500 Received: from name.redhat.com (ovpn-112-23.ams2.redhat.com [10.36.112.23]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q1SGAvAH014868 for ; Tue, 28 Feb 2012 11:11:12 -0500 From: marios@redhat.com To: dev@deltacloud.apache.org Subject: [PATCH 6/7] Minor changes to filter_all and report_error to make sure errors (e.g. 401 authentication) are propagated back to client. Date: Tue, 28 Feb 2012 18:10:54 +0200 Message-Id: <1330445455-2944-7-git-send-email-marios@redhat.com> In-Reply-To: <1330445455-2944-1-git-send-email-marios@redhat.com> References: <1330445455-2944-1-git-send-email-marios@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 X-Virus-Checked: Checked by ClamAV on apache.org From: marios Signed-off-by: marios --- .../lib/deltacloud/helpers/application_helper.rb | 26 +++++++++++++------- 1 files changed, 17 insertions(+), 9 deletions(-) diff --git a/server/lib/deltacloud/helpers/application_helper.rb b/server/lib/deltacloud/helpers/application_helper.rb index d44f108..b54ec41 100644 --- a/server/lib/deltacloud/helpers/application_helper.rb +++ b/server/lib/deltacloud/helpers/application_helper.rb @@ -76,15 +76,23 @@ module ApplicationHelper filter.merge!(:state => params[:state]) if params[:state] filter = {} if filter.keys.size.eql?(0) singular = model.to_s.singularize.to_sym - @benchmark = Benchmark.measure do - @elements = driver.send(model.to_sym, credentials, filter) + begin + @benchmark = Benchmark.measure do + @elements = driver.send(model.to_sym, credentials, filter) + end + rescue + @exception = $! end - headers['X-Backend-Runtime'] = @benchmark.real.to_s - instance_variable_set(:"@#{model}", @elements) - respond_to do |format| - format.html { haml :"#{model}/index" } - format.xml { haml :"#{model}/index" } - format.json { convert_to_json(singular, @elements) } + if @elements + headers['X-Backend-Runtime'] = @benchmark.real.to_s + instance_variable_set(:"@#{model}", @elements) + respond_to do |format| + format.html { haml :"#{model}/index" } + format.xml { haml :"#{model}/index" } + format.json { convert_to_json(singular, @elements) } + end + else + report_error(@exception.code) end end @@ -106,7 +114,7 @@ module ApplicationHelper end def report_error(code=nil) - @error, @code = request.env['sinatra.error'], code + @error, @code = (request.env['sinatra.error'] || @exception), code @code = 500 if not @code and not @error.class.method_defined? :code response.status = @code || @error.code respond_to do |format| -- 1.7.6.5