From: Alexey Z. <ind...@gm...> - 2007-12-20 06:48:22
|
Wouldn't it be a better idea to store backtrace and forward it higher, along with exception, so it can be used when needed, but wouldn't take log-space otherwise? I strongly believe, that printing is a task for application, not for a library (with an exceptional case of a printing library) On 12/20/07, Zenaan Harkness <ze...@fr...> wrote: > Hello, here's patch #2 :) > > This one adds a simple printStackTrace, around object creation time. > > Without this, when a ctor or a newly-created object (I think), and a > setXXX method of such an object (I have tested - faced this problem), > throws an exception, eg a NullPointerException, the name of the > exception (eg "NullPointerException") as well as the stack trace for my > own code (the client code of jvYaml) which would normally pinpoint the > exception, is completely consumed and is not displayed to the user when > running their (my) code. > > So, dumping the stack at the specified point in SafeConstructorImpl > solves this problem. > > Both this and the previous patch I am using on a daily basis in my > running code. > > Regards > Zen > > > --- > src/org/jvyaml/SafeConstructorImpl.java | 2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/src/org/jvyaml/SafeConstructorImpl.java b/src/org/jvyaml/SafeConstructorImpl.java > index 33da8f5..c3e29e2 100644 > --- a/src/org/jvyaml/SafeConstructorImpl.java > +++ b/src/org/jvyaml/SafeConstructorImpl.java > @@ -366,6 +366,8 @@ public class SafeConstructorImpl extends BaseConstructorImpl { > } > } > } catch(final Exception e) { > + // to make debugging for YAML client code sane, we must dump stack: > + e.printStackTrace(); > throw new YAMLException("Can't construct a java object from class " + pref + ": " + e.toString()); > } > return outp; > -- > 1.5.3.7.1066.g7a4a2e > > > -- > Homepage: www.SoulSound.net -- Free Australia: www.UPMART.org > Please respect the confidentiality of this email as sensibly warranted. > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services > for just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Yaml-core mailing list > Yam...@li... > https://lists.sourceforge.net/lists/listinfo/yaml-core > -- Alexey Zakhlestin http://blog.milkfarmsoft.com/ |