Sha256: 498fbe37497e7ce2c7865371842bbafe7e100ffcdec17d27bb8a40890628d2c1

Contents?: true

Size: 1.75 KB

Versions: 21

Compression:

Stored size: 1.75 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")
      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

21 entries across 21 versions & 2 rubygems

Version Path
neetob-ud-1.0.59 lib/neetob/exception_handler.rb
neetob-ud-0.2.8 lib/neetob/exception_handler.rb
neetob-ud-0.2.6 lib/neetob/exception_handler.rb
neetob-ud-0.2.4 lib/neetob/exception_handler.rb
neetob-ud-0.2.3 lib/neetob/exception_handler.rb
neetob-ud-0.2.2 lib/neetob/exception_handler.rb
neetob-ud-0.2.1 lib/neetob/exception_handler.rb
neetob-ud-0.2.0 lib/neetob/exception_handler.rb
neetob-ud-0.1.3 lib/neetob/exception_handler.rb
neetob-ud-0.1.2 lib/neetob/exception_handler.rb
neetob-ud-0.1.1 lib/neetob/exception_handler.rb
neetob-ud-0.1.0 lib/neetob/exception_handler.rb
neetob-ud-0.2.14 lib/neetob/exception_handler.rb
neetob-ud-0.2.13 lib/neetob/exception_handler.rb
neetob-0.1.4 lib/neetob/exception_handler.rb
neetob-ud-0.2.11 lib/neetob/exception_handler.rb
neetob-ud-0.2.9 lib/neetob/exception_handler.rb
neetob-ud-0.2.5 lib/neetob/exception_handler.rb
neetob-0.1.2 lib/neetob/exception_handler.rb
neetob-0.1.1 lib/neetob/exception_handler.rb