Sha256: c11e4deef6717a3e365380e43d57a79848040eb3ab9db77d8bbe4f1ab65e81c1

Contents?: true

Size: 734 Bytes

Versions: 8

Compression:

Stored size: 734 Bytes

Contents

module PolyglotIos
  class ErrorHandler
    extend Helper::Terminal

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

      def handle(e)
        prompt.error(
          case e
          when JsonApiClient::Errors::NotAuthorized
            "You are not authorized. Please call `polyglot 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
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
ios_polyglot_cli-2.4.0 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.3.0 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.2.2 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.2.1 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.2.0 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.1.1 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.1.0 lib/ios_polyglot_cli/error_handler.rb
ios_polyglot_cli-2.0.1 lib/ios_polyglot_cli/error_handler.rb