Module: XenAPI::ErrorFactory
- Defined in:
- lib/xenapi/error.rb
Constant Summary collapse
- API_ERRORS =
{ "SESSION_AUTHENTICATION_FAILED" => AuthenticationError, "HOST_IS_SLAVE" => NotMasterError, "HOST_STILL_BOOTING" => ConnectionError }
- TRANSLATIONS =
{ EOFError => ExpirationError, OpenSSL::SSL::SSLError => ExpirationError, Errno::EHOSTUNREACH => ConnectionError, Errno::ECONNREFUSED => ConnectionError, Errno::EPIPE => ConnectionError, Timeout::Error => TimeoutError }
Class Method Summary collapse
Class Method Details
.create(*args) ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/xenapi/error.rb', line 52 def create(*args) key = args[0] = args.join(": ") error_class = API_ERRORS[key] return error_class.new if error_class Error.new end |
.wrap(error) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/xenapi/error.rb', line 61 def wrap(error) return error if error.is_a? Error error_class = TRANSLATIONS[error.class] return error_class.new error.to_s if error_class Error.new "<#{error.class}> #{error}" end |