Re: [PATCH] jvyaml sanity: printStackTrace for client object creation exceptions

"Alexey Zakhlestin" <[email protected]>
Newsgroups gmane.text.yaml.general
Message-ID <[email protected]>
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 <[email protected]> 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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/yaml-core
>


-- 
Alexey Zakhlestin
http://blog.milkfarmsoft.com/

-------------------------------------------------------------------------
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.