You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/07/23 11:06:00 UTC
[1/6] git commit: Core: Added handler for 403 exceptions
Updated Branches:
refs/heads/master 9e8725742 -> ba70143ef
Core: Added handler for 403 exceptions
Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/ba70143e
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/ba70143e
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/ba70143e
Branch: refs/heads/master
Commit: ba70143ef7b24c32ccaf70bf622dc40282e995b2
Parents: fbd5ea9
Author: Michal Fojtik <mf...@redhat.com>
Authored: Fri Jul 20 17:43:47 2012 +0200
Committer: Michal fojtik <mf...@redhat.com>
Committed: Fri Jul 20 17:44:28 2012 +0200
----------------------------------------------------------------------
server/lib/deltacloud/drivers/exceptions.rb | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/ba70143e/server/lib/deltacloud/drivers/exceptions.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/exceptions.rb b/server/lib/deltacloud/drivers/exceptions.rb
index d5a8bc3..5e679a5 100644
--- a/server/lib/deltacloud/drivers/exceptions.rb
+++ b/server/lib/deltacloud/drivers/exceptions.rb
@@ -37,6 +37,13 @@ module Deltacloud
end
end
+ class ForbiddenError < DeltacloudException
+ def initialize(e, message=nil)
+ message ||= e.message
+ super(403, e.class.name, message, e.backtrace)
+ end
+ end
+
class UnknownMediaTypeError < DeltacloudException
def initialize(e, message=nil)
message ||= e.message
@@ -136,6 +143,7 @@ module Deltacloud
return @handler if @handler
case @status
when 401 then Deltacloud::ExceptionHandler::AuthenticationFailure.new(e, @message)
+ when 403 then Deltacloud::ExceptionHandler::ForbiddenError.new(e, @message)
when 404 then Deltacloud::ExceptionHandler::ObjectNotFound.new(e, @message)
when 406 then Deltacloud::ExceptionHandler::UnknownMediaTypeError.new(e, @message)
when 405 then Deltacloud::ExceptionHandler::MethodNotAllowed.new(e, @message)
@@ -176,7 +184,7 @@ module Deltacloud
Deltacloud::ExceptionHandler::exceptions.each do |exdef|
if exdef.match?($!)
new_exception = exdef.handler($!)
- m = new_exception.message.nil? ? $!.message : new_exception.message
+ m = (new_exception && !new_exception.message.nil?) ? new_exception.message : $!.message
unless ENV['RACK_ENV'] == 'test'
$stderr.send(report_method, "#{[$!.class.to_s, m].join(':')}\n#{$!.backtrace[0..10].join("\n")}")
end