From 02d2d3cf699f2c8a1e078d5e5e72f76ec6706da6 Mon Sep 17 00:00:00 2001 From: Stephen Blackstone Date: Tue, 5 Jan 2016 22:53:38 -0500 Subject: Provide a better error message if a user mistypes the name of script with runner Add tests for detecting bad options for runner --- railties/lib/rails/commands/runner.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'railties/lib/rails/commands/runner.rb') diff --git a/railties/lib/rails/commands/runner.rb b/railties/lib/rails/commands/runner.rb index 86bce9b2fe..babb197ba1 100644 --- a/railties/lib/rails/commands/runner.rb +++ b/railties/lib/rails/commands/runner.rb @@ -58,5 +58,11 @@ elsif File.exist?(code_or_file) $0 = code_or_file Kernel.load code_or_file else - eval(code_or_file, binding, __FILE__, __LINE__) + begin + eval(code_or_file, binding, __FILE__, __LINE__) + rescue SyntaxError,NameError => err + $stderr.puts "Please specify a valid ruby command or the path of a script to run." + $stderr.puts "Run '#{$0} -h' for help." + exit 1 + end end -- cgit v1.2.3