Class: VagrantPlugins::XenServer::MyUtil::Exnhandler
- Inherits:
-
Object
- Object
- VagrantPlugins::XenServer::MyUtil::Exnhandler
- Defined in:
- lib/vagrant-xenserver/util/exnhandler.rb
Class Method Summary collapse
Class Method Details
.def(api, error) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/vagrant-xenserver/util/exnhandler.rb', line 9
def(api,error)
# Default case: raise generic API error
raise Errors::APIError,
api: api,
error: String(error)
end
|
.handle(api, error) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/vagrant-xenserver/util/exnhandler.rb', line 16 def self.handle(api,error) case error[0] when "IMPORT_ERROR" case error[1] when "404 Not Found" raise Errors::Import404 else Exnhandler.def(api,error) end when "SR_BACKEND_FAILURE_44" raise Errors::InsufficientSpace else raise Errors::APIError, api: api, error: String(error) end end |
.handle_xenapiexn(api, e, logger) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-xenserver/util/exnhandler.rb', line 34 def self.handle_xenapiexn(api,e,logger) case e when XenApi::Errors::SRFull raise Errors::InsufficientSpace when XenApi::Errors::GenericError # Grotesque hack - get the error array back by parsing the string # representation as JSON. Bleurgh! self.handle(api,JSON.parse(e.)) else self.handle(api,e) end end |