class PolyglotFlutter::ErrorHandler

Public Class Methods

handle(e) click to toggle source
# File lib/flutter_polyglot_cli/error_handler.rb, line 12
def handle(e)
  prompt.error(
    case e
    when JsonApiClient::Errors::NotAuthorized
      "You are not authorized. Please call `polyflut login` and provide correct credentials."
    when JsonApiClient::Errors::AccessDenied
      "You don't have the permission to access requested project."
    when Errno::ENOENT
      "We could not find a file that we need:\n\n#{e.message}"
    else
      "An error happened. This might help:\n\n#{e.message}"
    end
  )
end
rescuable() { || ... } click to toggle source
# File lib/flutter_polyglot_cli/error_handler.rb, line 6
def rescuable
  yield
rescue StandardError => e
  handle(e)
end