Christian Neukirchen wrote:
> Eli Bendersky <eliben / gmail.com> writes:
> 
>>>> possible without deconstructing the raised msg ?
>>
>> Thanks for your suggestion, it was clear to me that this is possible, 
>> but I seek a more 'sane' way of doing it. What if REXML changes the 
>> format of the message slightly in the next version - the regexes won't 
>> match any longer. I don't see why there can't be a short way to print a 
>> message that is useful to an end user.
>>
>>
>> REXML is praised as *the* XML parsing library of Ruby and is part of the 
>> standard library, surely someone noticed its useless error reporting ?!
> 
> Why didn't you bother to just look in the code? :-)
> 
> [~/src/ruby-1.8.4/lib/rexml/parseexception.rb:]
> module REXML
>   class ParseException < RuntimeError
>     ...
>     def position
>       @source.current_line[0] if @source and defined? 
> @source.current_line and
>       @source.current_line
>     end
> 
>     def line
>       @source.current_line[2] if @source and defined? 
> @source.current_line and
>       @source.current_line
>     end
> 
>     def context
>       @source.current_line
>     end
>   end
> end

I did look at the code before posting, and it doesn't help. Position / 
line can be printed separately, true (although they are completely 
useless most of the times), but the message can not be printed 
separately without the stack trace, for some truly obscure reason.

See the 'to_s' method of ParseException




-- 
Posted via http://www.ruby-forum.com/.