title: Throwing custom exception from Jackson Serializer in Java
body: <p>I was wondering if anyone could help - I am writing a custom Json serializer, extending from JsonSerializer, and I want to wrap any exceptions that could be thrown in my own custom exception, extended from IOException. However, whenever I run any unit tests (using junit) to confirm that the exception is thrown it is failing, saying that - </p>
  
  <pre><code>Expected: (exception with message a string containing "Unable to serialize!" and an instance of com.cybersource.profile.serializer.MySerializerException)
   got: &lt;com.fasterxml.jackson.databind.JsonMappingException: Unexpected IOException (of type com.cybersource.profile.serializer.MySerializerException): Unable to serialize!&gt;
  </code></pre>
  
  <p>Any idea how to get around this, or is it not possible to throw a custom exception?</p>