-
-
Save ConradIrwin/8992b265c63ff966d0d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/pry.rb b/lib/pry.rb | |
index 718e3e4..c2e030b 100644 | |
--- a/lib/pry.rb | |
+++ b/lib/pry.rb | |
@@ -65,9 +65,15 @@ class Pry | |
end | |
# Will only show the first line of the backtrace | |
- DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _| | |
- output.puts "#{exception.class}: #{exception.message}" | |
- output.puts "from #{exception.backtrace.first}" | |
+ DEFAULT_EXCEPTION_HANDLER = proc do |output, exception, _pry_| | |
+ if exception.equal? _pry_.result | |
+ output.puts "#{exception.class}: #{exception.message}" | |
+ output.puts "from #{exception.backtrace.first}" | |
+ elsif SyntaxError == exception | |
+ output.puts "SyntaxError: #{exception.message}" | |
+ else | |
+ output.puts "Error: #{exception.message}" | |
+ end | |
end | |
DEFAULT_PROMPT_NAME = 'pry' | |
diff --git a/lib/pry/pry_instance.rb b/lib/pry/pry_instance.rb | |
index 21b3acb..1ef55c5 100644 | |
--- a/lib/pry/pry_instance.rb | |
+++ b/lib/pry/pry_instance.rb | |
@@ -300,13 +300,13 @@ class Pry | |
# eval_string will probably be mutated by this method | |
retrieve_line(eval_string, target) | |
rescue CommandError, Slop::InvalidOptionError, MethodSource::SourceNotFoundError => e | |
- output.puts "Error: #{e.message}" | |
+ exception_handler.call(output, e, self) | |
end | |
begin | |
break if Pry::Code.complete_expression?(eval_string) | |
rescue SyntaxError => e | |
- output.puts "SyntaxError: #{e.message.sub(/.*syntax error, */m, '')}" | |
+ exception_handler.call(output, e, self) | |
eval_string = "" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment