private static void handleException(Exception ex, boolean serialization, String fieldName,
      Object obj) {
    if (ex instanceof CancelException) {
      // fix for bug 43936
      throw (CancelException) ex;
    } else if (ex instanceof NonPortableClassException) {
      throw (NonPortableClassException) ex;
    } else {
      throw new PdxSerializationException((serialization ? "Serialization" : "Deserialization")
          + " error on field " + fieldName + " for class " + obj.getClass().getName(), ex);
    }
  }
Using the given PdxWriter, write out the relevant fields for the object instance passed in.

@param writer the <code>PdxWriter</code> to use when writing the object
@param obj the object to serialize
@return <code>true</code> if the object was serialized, <code>false</code> otherwise
geode-core/src/main/java/org/apache/geode/pdx/internal/AutoSerializableManager.java