# File lib/hammer_cli/exception_handler.rb, line 25 def handle_exception(e, options={}) @options = options handler = mappings.reverse.find { |m| e.class.respond_to?(:"<=") ? e.class <= m[0] : false } return send(handler[1], e) if handler raise e end
# File lib/hammer_cli/exception_handler.rb, line 12 def mappings [ [Exception, :handle_general_exception], # catch all [Clamp::HelpWanted, :handle_help_wanted], [Clamp::UsageError, :handle_usage_exception], [RestClient::ResourceNotFound, :handle_not_found], [RestClient::Unauthorized, :handle_unauthorized], [ApipieBindings::DocLoadingError, :handle_apipie_docloading_error], [ApipieBindings::MissingArgumentsError, :handle_apipie_missing_arguments_error], [HammerCLI::ModuleDisabledButRequired, :handle_generic_config_error] ] end
# File lib/hammer_cli/exception_handler.rb, line 91 def handle_apipie_docloading_error(e) rake_command = "rake apipie:cache" print_error _("Could not load the API description from the server") + "\n - " + _("is the server down?") + "\n - " + _("was '%s' run on the server when using apipie cache? (typical production settings)") % rake_command log_full_error e HammerCLI::EX_CONFIG end
# File lib/hammer_cli/exception_handler.rb, line 100 def handle_apipie_missing_arguments_error(e) message = _("Missing arguments for %s") % "'#{e.params.join("', '")}'" print_error message log_full_error e, message HammerCLI::EX_USAGE end
# File lib/hammer_cli/exception_handler.rb, line 61 def handle_general_exception(e) print_error _("Error: %s") % e.message log_full_error e HammerCLI::EX_SOFTWARE end
# File lib/hammer_cli/exception_handler.rb, line 107 def handle_generic_config_error(e) print_error e.message log_full_error e HammerCLI::EX_CONFIG end
# File lib/hammer_cli/exception_handler.rb, line 74 def handle_help_wanted(e) print_message e.command.help HammerCLI::EX_OK end
# File lib/hammer_cli/exception_handler.rb, line 79 def handle_not_found(e) print_error e.message log_full_error e HammerCLI::EX_NOT_FOUND end
# File lib/hammer_cli/exception_handler.rb, line 67 def handle_usage_exception(e) print_error (_("Error: %{message}") + "\n\n" + _("See: '%{path} --help'")) % {:message => e.message, :path => e.command.invocation_path} log_full_error e HammerCLI::EX_USAGE end
# File lib/hammer_cli/exception_handler.rb, line 53 def log_full_error(e, message = e.message) backtrace = e.backtrace || [] error = "\n\n#{e.class} (#{message}):\n " + backtrace.join("\n ") + "\n\n" @logger.error error end
Generated with the Darkfish Rdoc Generator 2.