Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log when a property is left out of serialised result due to exception #136

Merged
merged 1 commit into from
Jan 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Allows caller to intercept exporting of properties.
Expand All @@ -12,6 +14,9 @@
* @author James Dumay
*/
public abstract class ExportInterceptor {

public static final Logger LOGGER = Logger.getLogger(ExportInterceptor.class.getName());

/**
* Constant to tell if return of {@link ExportInterceptor#getValue(Property, Object, ExportConfig)} should be skipped.
*
Expand Down Expand Up @@ -41,6 +46,7 @@ public Object getValue(Property property, Object model, ExportConfig config) thr
return property.getValue(model);
} catch (IllegalAccessException | InvocationTargetException e) {
if(config.isSkipIfFail()) {
LOGGER.log(Level.WARNING,"Failed to get \"" + property.name + "\" from a " + model.getClass().getName(), e);
return SKIP;
}
throw new IOException("Failed to write " + property.name + ":" + e.getMessage(), e);
Expand Down