Sha256: 390953a28d2b120368c3b9f447510e74543a0b2b9134ac9711fe4ce4347f1ae7

Contents?: true

Size: 913 Bytes

Versions: 14

Compression:

Stored size: 913 Bytes

Contents

module HammerCLIForemanOpenscap
  class ExceptionHandler < HammerCLIForeman::ExceptionHandler
    def mappings
      [
        [RestClient::InternalServerError, :handle_internal_error],
        [RestClient::UnprocessableEntity, :handle_unprocessable_entity],
        [HammerCLIForemanOpenscap::DownloadError, :handle_download_error]
      ] + super
    end

    protected

    def handle_download_error(e)
      print_error e.message
      log_full_error e
    end

    def handle_internal_error(e)
      handle_scap_error(e)
      HammerCLI::EX_SOFTWARE
    end

    def handle_unprocessable_entity(e)
      handle_scap_error(e)
      HammerCLI::EX_DATAERR
    end

    def handle_scap_error(e)
      response = JSON.parse(e.response)
      response = HammerCLIForeman.record_to_common_format(response)
      print_error(response["message"] || response["full_messages"])
      log_full_error e
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
hammer_cli_foreman_openscap-0.2.1 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.2.0 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.13 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.12 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.11 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.10 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.9 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.8 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.7 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.6 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.5 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.4 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.3 lib/hammer_cli_foreman_openscap/exception_handler.rb
hammer_cli_foreman_openscap-0.1.2 lib/hammer_cli_foreman_openscap/exception_handler.rb