mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +01:00
Do not crash if preferences.txt can't be written
This commit is contained in:
parent
99fe051c4a
commit
9eeb79fed4
@ -1,14 +1,9 @@
|
||||
package processing.app;
|
||||
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
import static processing.app.I18n.format;
|
||||
import static processing.app.I18n.tr;
|
||||
|
||||
import cc.arduino.i18n.Languages;
|
||||
import processing.app.helpers.PreferencesHelper;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.legacy.PConstants;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.Font;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
@ -18,7 +13,13 @@ import java.util.Iterator;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static processing.app.I18n.tr;
|
||||
import org.apache.commons.compress.utils.IOUtils;
|
||||
|
||||
import cc.arduino.i18n.Languages;
|
||||
import processing.app.helpers.PreferencesHelper;
|
||||
import processing.app.helpers.PreferencesMap;
|
||||
import processing.app.legacy.PApplet;
|
||||
import processing.app.legacy.PConstants;
|
||||
|
||||
|
||||
public class PreferencesData {
|
||||
@ -136,6 +137,9 @@ public class PreferencesData {
|
||||
}
|
||||
|
||||
writer.flush();
|
||||
} catch (Throwable e) {
|
||||
System.err.println(format(tr("Could not write preferences file: {0}"), e.getMessage()));
|
||||
return;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(writer);
|
||||
}
|
||||
|
@ -566,12 +566,9 @@ public class PApplet {
|
||||
if (file == null) {
|
||||
throw new RuntimeException("File passed to createWriter() was null");
|
||||
} else {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("Couldn't create a writer for " +
|
||||
file.getAbsolutePath());
|
||||
throw new RuntimeException("Couldn't create a writer for " + file.getAbsolutePath(), e);
|
||||
}
|
||||
}
|
||||
//return null;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user