Ensure that stack-trace is included when exceptions are logged

Showing 1-5 of 5 messages
Ensure that stack-trace is included when exceptions are logged Thomas Hallgren 4/1/12 11:06 PM
The vomit method created an exception where the stack-trace from the
original exception was lost. This commit changes that by creating a
nested exception instead.

---------------- src/hirondelle/web4j/model/ModelCtorUtil.java
----------------
diff --git a/src/hirondelle/web4j/model/ModelCtorUtil.java b/src/
hirondelle/web4j/model/ModelCtorUtil.java
index bc065e6..efb8e92 100644
--- a/src/hirondelle/web4j/model/ModelCtorUtil.java
+++ b/src/hirondelle/web4j/model/ModelCtorUtil.java
@@ -140,7 +140,7 @@
     throw new RuntimeException(
       "Cannot reflectively construct Model Object of class "
       + aMOCtor.getDeclaringClass().getName() +
-      ", using arguments " + aArgValues + ". Underlying cause: " +
aEx.toString()
+      ", using arguments " + aArgValues + '.', aEx
     );
   }

Re: Ensure that stack-trace is included when exceptions are logged John O'Hanley 4/5/12 1:47 PM
Right. I think I'll keep the "Underlying cause.." part. It's redundant, but it doesn't hurt.  Sometimes the underlying cause is waaaaay down on a stack trace.
Re: Ensure that stack-trace is included when exceptions are logged Thomas Hallgren 4/5/12 2:20 PM
The reason I removed that wording is that when printing stack traces, it's reported with the phrase "Caused by". The
resulting output then become "Caused by: Underlying cause: ".

On 04/05/2012 10:47 PM, John O'Hanley wrote:
> Right. I think I'll keep the "Underlying cause.." part. It's redundant, but it doesn't hurt.  Sometimes the underlying
> cause is waaaaay down on a stack trace.
> --
> You received this message because you are subscribed to the Google Groups "web4j-users" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/web4j-users/-/4k0W6Bb-btAJ.
> To post to this group, send email to web4j...@googlegroups.com.
> To unsubscribe from this group, send email to web4j-users...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/web4j-users?hl=en.

Re: Ensure that stack-trace is included when exceptions are logged John O'Hanley 4/5/12 3:08 PM
Ok. I prefer this style:


    throw new RuntimeException(
      "Cannot reflectively construct Model Object of class "
      + aMOCtor.getDeclaringClass().getName() +
      ", using arguments " + aArgValues + ". " + aEx.toString(),
      aEx
    );

I would like to have the underlying exception message in the top level string too.
Re: Ensure that stack-trace is included when exceptions are logged Thomas Hallgren 4/5/12 11:22 PM
Yes, that makes a lot of sense.