Sha256: 5a3c4b39f99224837fd928e510c3f145aac8ca2b5037842bff50ba0ca3d9ff8a

Contents?: true

Size: 766 Bytes

Versions: 9

Compression:

Stored size: 766 Bytes

Contents

module PolyglotIos
  class ErrorHandler
    extend Helper::Terminal

    class << self
      def rescuable
        yield
      rescue => e
        handle(e)
      end

      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
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ios_polyglot_cli-2.8.1 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.8.0 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.7.3 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.7.2 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.7.1 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.7.0 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.6.3 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.6.2 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.6.1 lib/ios_polyglot_cli/error_handler.rb