Skip to content

Commit

Permalink
RHEV-M driver updated to support new error handling
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/deltacloud/trunk@1099078 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mfojtik committed May 3, 2011
1 parent 67769b4 commit 8cad9b7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
3 changes: 3 additions & 0 deletions server/lib/deltacloud/base_driver/exceptions.rb
Expand Up @@ -28,6 +28,9 @@ def initialize(e, details)
end

class BackendError < DeltacloudException

attr_accessor :cause

def initialize(e, details)
super(500, e.class.name, e.message, e.backtrace, details)
end
Expand Down
23 changes: 14 additions & 9 deletions server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
Expand Up @@ -277,15 +277,20 @@ def convert_realm(r, dc)
)
end

# Disabling this error catching will lead to more verbose messages
# on console (eg. response from RHEV-M API (so far I didn't figure our
# how to pass those message to our exception handling tool)
def catched_exceptions_list
{
:auth => [RestClient::Unauthorized],
:error => [RestClient::InternalServerError],
:glob => [ /(RestClient|RHEVM)::(\w+)/ ]
}
exceptions do

on /RestClient::Unauthorized/ do
status 401
end

on /RestClient::InternalServerError/ do
status 502
end

on /(RestClient|RHEVM)/ do
status 500
end

end

end
Expand Down
4 changes: 2 additions & 2 deletions server/tests/drivers/mock/api_test.rb
Expand Up @@ -69,7 +69,7 @@ def test_it_handles_unsupported_collections

with_provider("storage") do
get_auth_url '/api/instances'
last_response.status.should == 404
last_response.status.should == 403
end
end

Expand All @@ -79,7 +79,7 @@ def test_it_allows_accessing_docs

with_provider("storage") do
get_url '/api/docs/instances'
last_response.status.should == 404
last_response.status.should == 403
end
end

Expand Down

0 comments on commit 8cad9b7

Please sign in to comment.