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:
parent
b18ffc9776
commit
8f6c8770ab
3 changed files with 18 additions and 7 deletions
|
@ -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
|
||||
|
|
9
lib/fog/fogdocker/errors.rb
Normal file
9
lib/fog/fogdocker/errors.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
module Fog
|
||||
module Errors
|
||||
module Fogdocker
|
||||
class ServiceError < Fog::Errors::Error; end
|
||||
class AuthenticationError < ServiceError; end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue