class PolyglotCli::ErrorHandler

Public Class Methods

handle(e) click to toggle source
# File lib/polyglot_cli/error_handler.rb, line 12
def handle(e)
  prompt.error(
    case e
    when JsonApiClient::Errors::NotAuthorized
      'You are not authorized.'
    when Errno::ENOENT
      'We could not find a file that we need. Please try logging in and initializing the project.'
    else
      "An error happened. The elves are against you. This might help:\n\n#{e.message}"
    end
  )
end
rescuable() { || ... } click to toggle source
# File lib/polyglot_cli/error_handler.rb, line 6
def rescuable
  yield
rescue => e
  handle(e)
end