format-message / message-format-rb

Parse and format i18n messages using ICU MessageFormat patterns
MIT License
17 stars 14 forks source link

Make `SyntaxError` display the message when printed #2

Closed ptarjan closed 8 years ago

ptarjan commented 8 years ago

This seems to be the way to make ruby errors look best. I tested it like this:

$ 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
vanwagonet commented 8 years ago

Looks great! Thanks!

ptarjan commented 8 years ago

Thanks for pulling in so fast. @thetalecrafter are you doing to ship a new gem or should I patch my local copy?

vanwagonet commented 8 years ago

I plan to ship a new version of the gem, but I need to find some time, and remember how to do it. :) I spend most of my time interacting with npm.

ptarjan commented 8 years ago

Thanks!

vanwagonet commented 8 years ago

k. Should be updated to 0.0.4 on rubygems.org