rspec / rspec-core

RSpec runner and formatters
http://rspec.info
MIT License
1.23k stars 765 forks source link

Change syntax error handling to print in cli #3026

Closed JonRowe closed 1 year ago

JonRowe commented 1 year ago

Building off @schneems work in #3015 this moves the error handling higher in priority (to fix the handling) and then rather than re-raising uses the detailed_message as part of our exception printing producing:

bundle exec rspec spec/syntax_spec.rb

While loading ./spec/syntax_spec.rb a `raise SyntaxError` occurred, RSpec will now quit.
Failure/Error: require './spec/syntax.rb'

SyntaxError:
  --> /Users/jon/Code/Scratch/RSpecSandbox/spec/syntax.rb
  Unmatched keyword, missing `end' ?
    1  module Cutlass
    2    class LocalBuildpack
  > 3      private
  > 4      attr_reader :image_name
  > 5      def initialize(directory:)
    8    end
    9  end
  /Users/jon/Code/Scratch/RSpecSandbox/spec/syntax.rb:9: syntax error, unexpected end-of-input (SyntaxError)
# ./spec/syntax_spec.rb:1:in `require'
# ./spec/syntax_spec.rb:1:in `<top (required)>'
# ./.bundle/gems/ruby/3.2.0/gems/bundler-2.3.7/exe/bundler:4:in `load'
# ./.bundle/gems/ruby/3.2.0/gems/bundler-2.3.7/exe/bundler:4:in `<top (required)>'

Finished in 0.00011 seconds (files took 0.04363 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples
schneems commented 1 year ago

Thanks!

JonRowe commented 10 months ago

Released in 3.13.0, apologies it has taken so long.