Class: PolyglotIos::ErrorHandler

Inherits:
Object
  • Object
show all
Extended by:
Helper::Terminal
Defined in:
lib/ios_polyglot_cli/error_handler.rb

Class Method Summary collapse

Methods included from Helper::Terminal

generate_token_message, prompt, success

Class Method Details

.handle(e) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/ios_polyglot_cli/error_handler.rb', line 12

def handle(e)
  case e
  when JsonApiClient::Errors::NotAuthorized
    prompt.error("You are not authorized. Please check your token and its validity.")
    prompt.warn(generate_token_message())
  when JsonApiClient::Errors::AccessDenied
    prompt.error("You don't have the permission to access requested project.")
  when Errno::ENOENT
    prompt.error("We could not find a file that we need:\n\n#{e.message}")
  else
    prompt.error("An error happened. This might help:\n\n#{e.message}")
  end
end

.rescuableObject



6
7
8
9
10
# File 'lib/ios_polyglot_cli/error_handler.rb', line 6

def rescuable
  yield
rescue => e
  handle(e)
end