class HammerCLIKatello::ExceptionHandler
Public Instance Methods
Source
# File lib/hammer_cli_katello/exception_handler.rb, line 4 def mappings super + [ [RestClient::InternalServerError, :handle_internal_error], [RestClient::BadRequest, :handle_bad_request] ] end
Calls superclass method
Protected Instance Methods
Source
# File lib/hammer_cli_katello/exception_handler.rb, line 28 def handle_bad_request(e) handle_katello_error(e) HammerCLI::EX_NOT_FOUND end
Source
# File lib/hammer_cli_katello/exception_handler.rb, line 13 def handle_internal_error(e) handle_katello_error(e) HammerCLI::EX_SOFTWARE end
Source
# File lib/hammer_cli_katello/exception_handler.rb, line 33 def handle_katello_error(e) begin response = JSON.parse(e.response) response = HammerCLIForeman.record_to_common_format(response) # Check multiple possible keys that can contain error message: # - displayMessage for katello specific messages # - full_messages for for messages that come from rails # - message for foreman specific messages msg = response["displayMessage"] || response["full_messages"] || response["message"] rescue JSON::ParserError msg = e.message ensure msg ||= e.message end print_error(msg) log_full_error(e) end
Source
# File lib/hammer_cli_katello/exception_handler.rb, line 23 def handle_not_found(e) handle_katello_error(e) HammerCLI::EX_NOT_FOUND end
Source
# File lib/hammer_cli_katello/exception_handler.rb, line 18 def handle_unprocessable_entity(e) handle_katello_error(e) HammerCLI::EX_DATAERR end