title: How to make Jackson throw exception as is when deserialization mapping fail
body: <p><a href="http://jackson.codehaus.org/" rel="noreferrer">Jackson</a> has a weird behavior in handling Exceptions that occur during deserialization mapping: it throws a <code>JsonMappingException</code> whose <code>.getCause()</code> returns the innermost of the exception chain.</p>
  
  <pre><code>//in main
  ObjectMapper jsonMapper = new ObjectMapper();
  String json = "{\"id\": 1}";
  try {
      Q q = jsonMapper.readValue(json, Q.class);
  } catch (JsonMappingException e) {
      System.out.println(e.getCause()); //java.lang.RuntimeException: ex 2
  }
  
  //class Q
  public class Q {
      @JsonCreator
      public Q(@JsonProperty("id") int id) {
          throw new RuntimeException("ex 0", 
              new RuntimeException("ex 1", 
                  new RuntimeException("ex 2")));
      }
  }
  </code></pre>
  
  <p>In the code above, I use <code>jsonMapper.readValue(..)</code> to map the String <code>json</code> to an instance of class <code>Q</code> whose the constructor, marked <code>@JsonCreator</code>, throws a chain of <code>RuntimeException</code>: <code>"ex 0", "ex 1", "ex 2"</code>. When the mapping fail, I expected the line <code>System.out.println(e.getCause());</code> to print out <code>ex 0</code>, but it prints <code>ex 2</code>.</p>
  
  <p>Why Jackson decides to do this and is there a way to configure it so that it doesn't discard my <code>ex 0</code>? I have tried</p>
  
  <pre><code>jsonMapper.configure(DeserializationFeature.WRAP_EXCEPTIONS, false);
  </code></pre>
  
  <p>but it doesn't do anything.</p>