- Timestamp:
- 2019-04-01T22:01:06+02:00 (6 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/GpxExportAction.java
r14397 r14950 10 10 import java.io.File; 11 11 import java.io.IOException; 12 import java.nio.file.InvalidPathException; 12 13 import java.text.MessageFormat; 13 14 … … 21 22 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 22 23 import org.openstreetmap.josm.tools.CheckParameterUtil; 23 import org.openstreetmap.josm.tools.Logging;24 24 import org.openstreetmap.josm.tools.Shortcut; 25 25 … … 108 108 try { 109 109 exporter.exportData(file, layer); 110 } catch (IOException e) {111 Logging.error(e);110 } catch (IOException | InvalidPathException e) { 111 SaveActionBase.showAndLogException(e); 112 112 } 113 113 } -
trunk/src/org/openstreetmap/josm/actions/SaveActionBase.java
r14153 r14950 7 7 import java.io.File; 8 8 import java.io.IOException; 9 import java.nio.file.InvalidPathException; 9 10 import java.util.Collection; 10 11 import java.util.LinkedList; … … 26 27 import org.openstreetmap.josm.tools.Logging; 27 28 import org.openstreetmap.josm.tools.Shortcut; 29 import org.openstreetmap.josm.tools.Utils; 28 30 29 31 /** … … 121 123 } 122 124 MainApplication.getMainFrame().repaint(); 123 } catch (IOException e) {124 Logging.error(e);125 } catch (IOException | InvalidPathException e) { 126 showAndLogException(e); 125 127 return false; 126 128 } … … 240 242 PreferencesUtils.putListBounded(Config.getPref(), "file-open.history", maxsize, history); 241 243 } 244 245 static void showAndLogException(Exception e) { 246 GuiHelper.runInEDT(() -> 247 JOptionPane.showMessageDialog( 248 MainApplication.getMainFrame(), 249 tr("<html>An error occurred while saving.<br>Error is:<br>{0}</html>", 250 Utils.escapeReservedCharactersHTML(e.getClass().getSimpleName() + " - " + e.getMessage())), 251 tr("Error"), 252 JOptionPane.ERROR_MESSAGE 253 )); 254 255 Logging.error(e); 256 } 242 257 } -
trunk/src/org/openstreetmap/josm/gui/io/importexport/FileExporter.java
r12671 r14950 17 17 public abstract class FileExporter implements ActiveLayerChangeListener { 18 18 19 /** the ExtensionFileFilter filter used by this exporter */ 19 20 public final ExtensionFileFilter filter; 20 21 -
trunk/src/org/openstreetmap/josm/gui/io/importexport/GpxExporter.java
r14153 r14950 11 11 import java.io.IOException; 12 12 import java.io.OutputStream; 13 import java.nio.file.InvalidPathException;14 13 import java.text.MessageFormat; 15 14 import java.time.Year; … … 39 38 import org.openstreetmap.josm.tools.CheckParameterUtil; 40 39 import org.openstreetmap.josm.tools.GBC; 41 import org.openstreetmap.josm.tools.Logging;42 40 43 41 /** … … 206 204 } 207 205 208 try (OutputStream fo = Compression.getCompressedFileOutputStream(file)) { 209 new GpxWriter(fo).write(gpxData); 210 fo.flush(); 211 } catch (IOException | InvalidPathException ex) { 212 Logging.error(ex); 213 JOptionPane.showMessageDialog(MainApplication.getMainFrame(), tr("Error while exporting {0}:\n{1}", fn, ex.getMessage()), 214 tr("Error"), JOptionPane.ERROR_MESSAGE); 206 try (OutputStream fo = Compression.getCompressedFileOutputStream(file); GpxWriter writer = new GpxWriter(fo)) { 207 writer.write(gpxData); 215 208 } 216 209 } -
trunk/src/org/openstreetmap/josm/gui/io/importexport/OsmExporter.java
r14296 r14950 67 67 * @param noBackup if {@code true}, the potential backup file created if the output file already exists will be deleted 68 68 * after a successful export 69 * @throws IOException in case of IO errors 70 * @throws InvalidPathException when file name cannot be converted into a Path 69 71 * @throws IllegalArgumentException if {@code layer} is not an instance of {@code OsmDataLayer} 70 72 */ 71 public void exportData(File file, Layer layer, boolean noBackup) {73 public void exportData(File file, Layer layer, boolean noBackup) throws IOException { 72 74 if (!(layer instanceof OsmDataLayer)) { 73 75 throw new IllegalArgumentException( … … 81 83 } 82 84 83 private void save(File file, OsmDataLayer layer, boolean noBackup) {85 private void save(File file, OsmDataLayer layer, boolean noBackup) throws IOException { 84 86 File tmpFile = null; 85 87 try { 88 86 89 // use a tmp file because if something errors out in the process of writing the file, 87 90 // we might just end up with a truncated file. That can destroy lots of work. … … 98 101 } catch (IOException | InvalidPathException e) { 99 102 Logging.error(e); 100 JOptionPane.showMessageDialog(101 MainApplication.getMainFrame(),102 tr("<html>An error occurred while saving.<br>Error is:<br>{0}</html>",103 Utils.escapeReservedCharactersHTML(e.getClass().getSimpleName() + " - " + e.getMessage())),104 tr("Error"),105 JOptionPane.ERROR_MESSAGE106 );107 103 108 104 try { … … 121 117 ); 122 118 } 119 // re-throw original error 120 throw e; 123 121 } 124 122 }
Note:
See TracChangeset
for help on using the changeset viewer.