Sha256: d1e82b15db8741c53431476299d9ff062895c82498c5a1c79723dc7c10d03eed
Contents?: true
Size: 1.09 KB
Versions: 5
Compression:
Stored size: 1.09 KB
Contents
require 'hammer_cli/exception_handler' require 'hammer_cli_foreman/exceptions' module HammerCLIForeman class ExceptionHandler < HammerCLI::ExceptionHandler def mappings super + [ [HammerCLIForeman::OperationNotSupportedError, :handle_unsupported_operation], [RestClient::Forbidden, :handle_forbidden], [RestClient::UnprocessableEntity, :handle_unprocessable_entity], [ArgumentError, :handle_argument_error], ] end protected def handle_unprocessable_entity(e) response = JSON.parse(e.response) response = response[response.keys[0]] print_error response["full_messages"] HammerCLI::EX_DATAERR end def handle_argument_error(e) print_error e.message log_full_error e HammerCLI::EX_USAGE end def handle_forbidden(e) print_error "Forbidden - server refused to process the request" log_full_error e HammerCLI::EX_NOPERM end def handle_unsupported_operation(e) print_error e.message log_full_error e HammerCLI::EX_UNAVAILABLE end end end
Version data entries
5 entries across 5 versions & 1 rubygems