1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Raise docker-api errors up

This commit is contained in:
Daniel Lobato 2014-10-10 10:43:17 +02:00
parent b18ffc9776
commit 8f6c8770ab
3 changed files with 18 additions and 7 deletions

View file

@ -1,15 +1,9 @@
require 'fog/core'
require 'fog/fogdocker/errors'
module Fog
module Fogdocker
extend Fog::Provider
module Errors
class ServiceError < Fog::Errors::Error; end
class SecurityError < ServiceError; end
class NotFound < ServiceError; end
end
service(:compute, 'Compute')
end
end

View file

@ -0,0 +1,9 @@
module Fog
module Errors
module Fogdocker
class ServiceError < Fog::Errors::Error; end
class AuthenticationError < ServiceError; end
end
end
end

View file

@ -7,6 +7,14 @@ module Fog
raise ArgumentError, "action is a required parameter" unless options.key? :action
container = Docker::Container.get(options[:id])
downcase_hash_keys container.send(options[:action]).json
rescue Docker::Error::NotFoundError => e
raise Fog::Errors::Error::NotFound.new(e.message)
rescue Docker::Error::TimeoutError => e
raise Fog::Errors::Error::TimeoutError.new(e.message)
rescue Docker::Error::UnauthorizedError => e
raise Fog::Errors::Fogdocker::ServiceError::AuthenticationError.new(e.message)
rescue Docker::Error::DockerError => e
raise Fog::Errors::Fogdocker::ServiceError.new(e.message)
end
end