3

I've been running into some strange errors with UTF strings in ruby 1.9. Often ruby will complain on something like this:

warning: regexp match /.../n against to UTF-8 string

I'd like to be able to show a full stack trace on a warning, or apply some kind of monkey patch that i can override the default warning functionality. How would i do this?

2 Answers2

1

If the warning comes from Ruby code(instead of native C), you can overwrite Warning#warn, then the warning becomes an exception you will get the backtrace of course:

module Warning
  def warn(msg)
    raise msg
  end
end

Thanks to: Can you ask ruby to treat warnings as errors?

Fangxing
  • 5,716
  • 2
  • 49
  • 53
0

Try $DEBUG = true. That will cause at least some warnings to turn into errors.

Daniel Brockman
  • 18,826
  • 3
  • 29
  • 40