mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[ec2] extract NotFound errors and react properly to them in models
This commit is contained in:
parent
7033686193
commit
2c0aa3b1b2
9 changed files with 20 additions and 11 deletions
|
@ -26,7 +26,10 @@ require 'fog/parser'
|
|||
require 'fog/ssh'
|
||||
|
||||
module Fog
|
||||
class Error < StandardError; end
|
||||
module Errors
|
||||
class Error < StandardError; end
|
||||
class NotFound < Fog::Errors::Error; end
|
||||
end
|
||||
end
|
||||
|
||||
require 'fog/aws'
|
||||
|
@ -38,7 +41,7 @@ require 'fog/vcloud'
|
|||
|
||||
module Fog
|
||||
|
||||
class MockNotImplemented < Fog::Error; end
|
||||
class MockNotImplemented < Fog::Errors::Error; end
|
||||
|
||||
unless const_defined?(:VERSION)
|
||||
VERSION = '0.1.3'
|
||||
|
|
|
@ -2,7 +2,8 @@ module Fog
|
|||
module AWS
|
||||
module EC2
|
||||
|
||||
class Error < Fog::Error; end
|
||||
class Error < Fog::Errors::Error; end
|
||||
class NotFound < Fog::Errors::NotFound; end
|
||||
|
||||
def self.new(options={})
|
||||
|
||||
|
@ -226,7 +227,12 @@ module Fog
|
|||
})
|
||||
rescue Excon::Errors::Error => error
|
||||
if match = error.message.match(/<Code>(.*)<\/Code><Message>(.*)<\/Message>/)
|
||||
new_error = Fog::AWS::EC2::Error.new("#{match[1]} => #{match[2]}")
|
||||
new_error = case match[1].split('.').last
|
||||
when 'NotFound'
|
||||
Fog::AWS::EC2::NotFound.new(match[2])
|
||||
else
|
||||
Fog::AWS::EC2::Error.new("#{match[1]} => #{match[2]}")
|
||||
end
|
||||
new_error.set_backtrace(error.backtrace)
|
||||
raise new_error
|
||||
else
|
||||
|
|
|
@ -51,7 +51,7 @@ module Fog
|
|||
if public_ip
|
||||
all(public_ip).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
if image_id
|
||||
all(image_id).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
if key_name
|
||||
all(key_name).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ module Fog
|
|||
if group_name
|
||||
all(group_name).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ module Fog
|
|||
if server_id
|
||||
all(server_id).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ module Fog
|
|||
if snapshot_id
|
||||
all(snapshot_id).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ module Fog
|
|||
if volume_id
|
||||
all(volume_id).first
|
||||
end
|
||||
rescue Excon::Errors::BadRequest
|
||||
rescue Fog::Errors::NotFound
|
||||
nil
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue