Clear file system exceptions in a special way

This commit is contained in:
crschnick 2023-11-21 03:03:39 +00:00
parent e373a2d241
commit 1fdb46eee5

View file

@ -12,7 +12,11 @@ import io.xpipe.app.update.XPipeDistributionType;
import io.xpipe.app.util.LicenseProvider; import io.xpipe.app.util.LicenseProvider;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import java.io.*; import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.nio.file.FileSystemException;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -98,6 +102,16 @@ public class SentryErrorHandler implements ErrorHandler {
msgField.setAccessible(true); msgField.setAccessible(true);
msgField.set(copy, null); msgField.set(copy, null);
if (copy instanceof FileSystemException) {
var fileField = FileSystemException.class.getDeclaredField("file");
fileField.setAccessible(true);
fileField.set(copy, null);
var otherField = FileSystemException.class.getDeclaredField("other");
otherField.setAccessible(true);
otherField.set(copy, null);
}
var causeField = Throwable.class.getDeclaredField("cause"); var causeField = Throwable.class.getDeclaredField("cause");
causeField.setAccessible(true); causeField.setAccessible(true);
causeField.set(copy, adjustCopy(throwable.getCause(), true)); causeField.set(copy, adjustCopy(throwable.getCause(), true));