@@ -41,38 +41,32 @@ def formatted_backtrace(exception=@exception)
41
41
formatted_cause ( exception )
42
42
end
43
43
44
- if RSpec ::Support ::RubyFeatures . supports_exception_cause?
45
- def formatted_cause ( exception )
46
- last_cause = final_exception ( exception , [ exception ] )
47
- cause = [ ]
48
-
49
- if exception . cause
50
- cause << '------------------'
51
- cause << '--- Caused by: ---'
52
- cause << "#{ exception_class_name ( last_cause ) } :" unless exception_class_name ( last_cause ) =~ /RSpec/
53
-
54
- encoded_string ( exception_message_string ( last_cause ) ) . split ( "\n " ) . each do |line |
55
- cause << " #{ line } "
56
- end
44
+ def formatted_cause ( exception )
45
+ return [ ] unless RSpec ::Support ::RubyFeatures . supports_exception_cause?
57
46
58
- unless last_cause . backtrace . nil? || last_cause . backtrace . empty?
59
- lines = backtrace_formatter . format_backtrace ( last_cause . backtrace , example . metadata )
60
- lines = [ lines [ 0 ] ] unless RSpec . configuration . full_cause_backtrace
47
+ last_cause = final_exception ( exception , [ exception ] )
48
+ cause = [ ]
61
49
62
- lines . each do |line |
63
- cause << ( " #{ line } " )
64
- end
65
- end
50
+ if exception . cause
51
+ cause << '------------------'
52
+ cause << '--- Caused by: ---'
53
+ cause << "#{ exception_class_name ( last_cause ) } :" unless exception_class_name ( last_cause ) =~ /RSpec/
54
+
55
+ encoded_string ( exception_message_string ( last_cause ) ) . split ( "\n " ) . each do |line |
56
+ cause << " #{ line } "
66
57
end
67
58
68
- cause
69
- end
70
- else
71
- # :nocov:
72
- def formatted_cause ( _ )
73
- [ ]
59
+ unless last_cause . backtrace . nil? || last_cause . backtrace . empty?
60
+ lines = backtrace_formatter . format_backtrace ( last_cause . backtrace , example . metadata )
61
+ lines = [ lines [ 0 ] ] unless RSpec . configuration . full_cause_backtrace
62
+
63
+ lines . each do |line |
64
+ cause << ( " #{ line } " )
65
+ end
66
+ end
74
67
end
75
- # :nocov:
68
+
69
+ cause
76
70
end
77
71
78
72
def colorized_formatted_backtrace ( colorizer = ::RSpec ::Core ::Formatters ::ConsoleCodes )
0 commit comments