Sha256: 9413bdf0bf25aaa57296c75cc45755e33153cc66495d54968446c418aa7da0ff

Contents?: true

Size: 1.79 KB

Versions: 63

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

require_relative "./cli/base"

module Neetob
  class ExceptionHandler < CLI::Base
    attr_accessor :exception

    def initialize(exception)
      super()
      @exception = exception
    end

    def process
      case exception
      when Thor::RequiredArgumentMissingError
        ui.error(
          "#{exception.message}."\
          " Please use the \"help\" command to check all the required options and try again."
        )
      when Octokit::NotFound
        ui.error(
          "#{exception.message}."\
          " Please check the repositry name, repositry access, API endpoint and try again."
        )
      when Octokit::UnprocessableEntity
        ui.error(
          "Failed to complete the given request."\
          " Make sure that the given entity is correct and processable"\
          "#{exception.message}."
        )
      when Octokit::Unauthorized
        ui.error(
          "You are unauthorized to make API calls,"\
          " because the access token is either revoked or invalid or not set."\
          " Use \"neetob github login\" command to update or set the token.")
      when Octokit::Forbidden
        ui.error(
          "You don't have enough permissions to access 'bigbinary' organization."\
          " Please grant access to this org while authorizing via the browser.")
      when Errno::ENOENT
        ui.error(
          "#{exception.message}."\
          " Please check the given path and try again"
        )
      when JSON::ParserError
        ui.error(
          "There is a problem in parsing the JSON file."\
          " Please check and update the given JSON file."
        )
      when SystemExit
        ui.error(
          "Process exit with status code 1"
        )
      else
        ui.error(exception.message)
      end
    end
  end
end

Version data entries

63 entries across 63 versions & 1 rubygems

Version Path
neetob-0.5.16 lib/neetob/exception_handler.rb
neetob-0.5.15 lib/neetob/exception_handler.rb
neetob-0.5.14 lib/neetob/exception_handler.rb
neetob-0.5.13 lib/neetob/exception_handler.rb
neetob-0.5.12 lib/neetob/exception_handler.rb
neetob-0.5.11 lib/neetob/exception_handler.rb
neetob-0.5.10 lib/neetob/exception_handler.rb
neetob-0.5.9 lib/neetob/exception_handler.rb
neetob-0.5.8 lib/neetob/exception_handler.rb
neetob-0.5.7 lib/neetob/exception_handler.rb
neetob-0.5.6 lib/neetob/exception_handler.rb
neetob-0.5.5 lib/neetob/exception_handler.rb
neetob-0.5.4 lib/neetob/exception_handler.rb
neetob-0.5.3 lib/neetob/exception_handler.rb
neetob-0.5.2 lib/neetob/exception_handler.rb
neetob-0.5.1 lib/neetob/exception_handler.rb
neetob-0.5.0 lib/neetob/exception_handler.rb
neetob-0.4.37 lib/neetob/exception_handler.rb
neetob-0.4.36 lib/neetob/exception_handler.rb
neetob-0.4.35 lib/neetob/exception_handler.rb