Exception: Vagrant::Node::ExceptionMutator

Inherits:
RestException
  • Object
show all
Includes:
Errors
Defined in:
lib/vagrant-node/exceptions.rb

Instance Method Summary collapse

Methods inherited from RestException

#code

Constructor Details

#initialize(exception) ⇒ ExceptionMutator

Returns a new instance of ExceptionMutator.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vagrant-node/exceptions.rb', line 34

def initialize(exception)
  if (exception.is_a?(Vagrant::Errors::VagrantError))                   
    case exception               
    when BaseVMNotFound,
         BoxNotFound,
         BoxSpecifiedDoesntExist,
         MachineNotFound,
         NetworkNotFound,
         ProviderNotFound,
         VMNotFoundError,
         VagrantfileExistsError
      super(404,exception.message)
    when BoxNotSpecified,
         CLIInvalidOptions,
         CLIInvalidUsage,
         DestroyRequiresForce           
      super(400,exception.message)
    when ConfigInvalid,
         NameError,
         # ConfigValidationFailed,
         # DeprecationError,
         DownloaderFileDoesntExist,
         BoxProviderDoesntMatch,
         #BoxDownloadUnknownType,
         BoxAlreadyExists,
         ActiveMachineWithDifferentProvider,
         BoxUnpackageFailure,
         BoxUpgradeRequired, 
         BoxVerificationFailed,
         VMImportFailure               
      super(406,exception.message)           
    else
      super(500,exception.message)
    end
    
  else
    super(500,exception.message)
  end
  
end