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.4.34 lib/neetob/exception_handler.rb
neetob-0.4.33 lib/neetob/exception_handler.rb
neetob-0.4.32 lib/neetob/exception_handler.rb
neetob-0.4.31 lib/neetob/exception_handler.rb
neetob-0.4.30 lib/neetob/exception_handler.rb
neetob-0.4.28 lib/neetob/exception_handler.rb
neetob-0.4.27 lib/neetob/exception_handler.rb
neetob-0.4.26 lib/neetob/exception_handler.rb
neetob-0.4.24 lib/neetob/exception_handler.rb
neetob-0.4.23 lib/neetob/exception_handler.rb
neetob-0.4.22 lib/neetob/exception_handler.rb
neetob-0.4.21 lib/neetob/exception_handler.rb
neetob-0.4.20 lib/neetob/exception_handler.rb
neetob-0.4.19 lib/neetob/exception_handler.rb
neetob-0.4.16 lib/neetob/exception_handler.rb
neetob-0.4.15 lib/neetob/exception_handler.rb
neetob-0.4.14 lib/neetob/exception_handler.rb
neetob-0.4.13 lib/neetob/exception_handler.rb
neetob-0.4.12 lib/neetob/exception_handler.rb
neetob-0.4.11 lib/neetob/exception_handler.rb