Class: NeetoDeploy::ExceptionHandler

Inherits:
CLI::Base
  • Object
show all
Defined in:
lib/neeto_deploy/exception_handler.rb

Instance Attribute Summary collapse

Attributes inherited from CLI::Base

#ui

Instance Method Summary collapse

Methods inherited from CLI::Base

#create_config_dir

Constructor Details

#initialize(exception) ⇒ ExceptionHandler

Returns a new instance of ExceptionHandler.



9
10
11
12
# File 'lib/neeto_deploy/exception_handler.rb', line 9

def initialize(exception)
  super()
  @exception = exception
end

Instance Attribute Details

#exceptionObject

Returns the value of attribute exception.



7
8
9
# File 'lib/neeto_deploy/exception_handler.rb', line 7

def exception
  @exception
end

Instance Method Details

#processObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/neeto_deploy/exception_handler.rb', line 14

def process
  case exception
  when Thor::RequiredArgumentMissingError
    ui.error(
      "#{exception.message}."\
      ' Please use the "help" command to check all the required options and try again.'
    )
  when Errno::ENOENT
    ui.error(
      "#{exception.message}."\
      " Please check the given path and try again"
    )
  when SystemExit
    ui.error(
      "Process exit with status code 1"
    )
  else
    ui.error(exception.message)
  end
end