[REXML] ParseExtension

Hi,

I’m courious why REXML::ParseException inherits Exception
directly, instead of StandardError.

···


Nobu Nakada

nobu.nokada@softhome.net wrote in message news:200306160624.h5G6OG8U015227@sharui.nakada.kanuma.tochigi.jp

I’m courious why REXML::ParseException inherits Exception
directly, instead of StandardError.

There is no particular reason. I came from Java, and Exceptions are
higher level than Errors in Java, the reverse of how it is in Ruby, so
that’s how I originally wrote it.

— SER

Hi,

I’m courious why REXML::ParseException inherits Exception
directly, instead of StandardError.

There is no particular reason. I came from Java, and Exceptions are
higher level than Errors in Java, the reverse of how it is in Ruby, so
that’s how I originally wrote it.

It seems tiresome to use. I guess it’d be better to be a
subclass of RuntimeError which can be caught by simle rescue.
Furthermore, sorry if I’m missing something, you seem to mix
bare Exception, ParseException and RuntimeError inconsistently.

And, in parsers/baseparser.rb, “raise $!” hides further
backtrace. This might make debug harder.

Another thing I noticed is that #{} is used inside ‘’ literal,
at parsers/baseparser.rb:144.

···

At Tue, 17 Jun 2003 02:16:13 +0900, Sean Russell wrote:


Nobu Nakada

nobu.nokada@softhome.net wrote in message news:200306220055.h5M0tkuG024067@sharui.nakada.kanuma.tochigi.jp

It seems tiresome to use. I guess it’d be better to be a
subclass of RuntimeError which can be caught by simle rescue.

Hm. Ok.

Furthermore, sorry if I’m missing something, you seem to mix
bare Exception, ParseException and RuntimeError inconsistently.

Do I? I don’t remember conciously generating a RuntimeError; I may
generate plain Exceptions, although I tried to be consistent in using
ParseExceptions in the parser… I don’t use ParseExceptions anywhere
else in REXML, I hope.

And, in parsers/baseparser.rb, “raise $!” hides further
backtrace. This might make debug harder.

Oh, reraising an exception doesn’t preserve the backtrace? That
surprises me, and it’s not very helpful. I’ll check on that.

Another thing I noticed is that #{} is used inside ‘’ literal,
at parsers/baseparser.rb:144.

Thanks.

— SER

Hi,

Furthermore, sorry if I’m missing something, you seem to mix
bare Exception, ParseException and RuntimeError inconsistently.

Do I? I don’t remember conciously generating a RuntimeError; I may
generate plain Exceptions, although I tried to be consistent in using
ParseExceptions in the parser… I don’t use ParseExceptions anywhere
else in REXML, I hope.

Raising with just message sends RuntimeError, not Exception.
Ruby itself never raise raw Exception. You use such
RuntimeError, Exception and ParseException.

And, in parsers/baseparser.rb, “raise $!” hides further
backtrace. This might make debug harder.

Oh, reraising an exception doesn’t preserve the backtrace? That
surprises me, and it’s not very helpful. I’ll check on that.

You can do just `raise’ without arguments. Then the backtrace
is preserved.

···

At Tue, 24 Jun 2003 10:22:14 +0900, Sean Russell wrote:


Nobu Nakada

nobu.nokada@softhome.net wrote in message news:200306240808.h5O88TuG016078@sharui.nakada.kanuma.tochigi.jp

You can do just `raise’ without arguments. Then the backtrace
is preserved.

This is all changed for the next release. The parser now only ever
generates ParseExceptions, which now extends RuntimeError, and the
re-raising of exceptions preserves the backtrace.

Thanks for the suggestions.

— SER