Skip to content

Commit 39e917b

Browse files
committed
Make SyntaxError display the message when printed
This seems to be the way to make ruby errors look best. I tested it like this: ```ruby $ cat /tmp/a.rb class A < StandardError def initialize(a) @A = a end end class B < StandardError attr_reader :message def initialize(message) @message = message end end class C < StandardError def initialize(message) super(message) end end puts A.new('foo') puts A.new('foo').inspect puts A.new('foo').message puts B.new('foo') puts B.new('foo').inspect puts B.new('foo').message puts C.new('foo') puts C.new('foo').inspect puts C.new('foo').message $ ruby /tmp/a.rb A #<A: A> A B #<B: B> foo foo #<C: foo> foo ```
1 parent 0bbad34 commit 39e917b

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/message_format/parser.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -360,15 +360,14 @@ def self.parse ( pattern )
360360
#
361361
class SyntaxError < StandardError
362362

363-
attr_reader :message
364363
attr_reader :expected
365364
attr_reader :found
366365
attr_reader :offset
367366
attr_reader :line
368367
attr_reader :column
369368

370369
def initialize (message, expected, found, offset, line, column)
371-
@message = message
370+
super(message)
372371
@expected = expected
373372
@found = found
374373
@offset = offset

0 commit comments

Comments
 (0)