ruby - Problems catching unidecoder exceptions -
i'm trying out unidecoder gem , it's giving me problems strings:
require 'unidecoder' str = "\u00a3" str.to_ascii
#: (c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder/data/x00.yml): found unknown escape character while parsing quote d scalar @ line 2 column 3 c:/ruby193/lib/ruby/1.9.1/psych.rb:203:in
parse' c:/ruby193/lib/ruby/1.9.1/psych.rb:203:in
parse_stream' c:/ruby193/lib/ruby/1.9.1/psych.rb:151:inparse' c:/ruby193/lib/ruby/1.9.1/psych.rb:127:in
load' c:/ruby193/lib/ruby/1.9.1/psych.rb:297:inblock in load_file' c:/ruby193/lib/ruby/1.9.1/psych.rb:297:in
open' c:/ruby193/lib/ruby/1.9.1/psych.rb:297:inload_file' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:8:in
block in ' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:78:inyield' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:78:in
default' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:78:indecode_char' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:39:in
block in decode' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:37:ingsub' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:37:in
decode' c:/ruby193/lib/ruby/gems/1.9.1/gems/unidecoder-1.1.1/lib/unidecoder.rb:16:into_ascii' (irb):21 c:/ruby193/bin/irb:12:in
'>>
what's worse, can't catch error doing:
foo = str.to_ascii rescue 'x'
does know what's happening here?
rescue clause no parameter list, parameter defaults standarderror; looks unidecoder
raises kinda other exception, stacktrace seems incomplete (it should show exception type.)
Comments
Post a Comment