1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

Improve error message on empty command (Issue #299)

This commit is contained in:
Conrad Irwin 2011-10-15 01:09:26 -07:00
parent ffce50a392
commit 6f2ad38324

View file

@ -32,14 +32,18 @@ class Pry
if (meth = Pry::Method.from_str(name, target, opts))
set_file_and_dir_locals(meth.source_file)
meth
elsif name
command_error("The method '#{name}' could not be found.", omit_help)
else
# FIXME: better/more accurate error handling
message = "The method '#{name}' could not be found."
message << " Type `#{command_name} --help` for help." unless omit_help
raise CommandError, message
command_error("No method name given, and context is not a method.", omit_help)
end
end
def command_error(message, omit_help)
message += " Type `#{command_name} --help` for help." unless omit_help
raise CommandError, message
end
def make_header(meth, content=meth.source)
header = "\n#{Pry::Helpers::Text.bold('From:')} #{meth.source_file} "