Ticket #19407: 19407.patch
File 19407.patch, 2.6 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/command/SequenceCommand.java
7 7 import java.util.Collection; 8 8 import java.util.HashSet; 9 9 import java.util.Objects; 10 import java.util.stream.Collectors; 11 import java.util.stream.Stream; 10 12 11 13 import javax.swing.Icon; 12 14 … … 14 16 import org.openstreetmap.josm.data.osm.OsmPrimitive; 15 17 import org.openstreetmap.josm.tools.ImageProvider; 16 18 import org.openstreetmap.josm.tools.Utils; 19 import org.openstreetmap.josm.tools.bugreport.ReportedException; 17 20 18 21 /** 19 22 * A command consisting of a sequence of other commands. Executes the other commands … … 104 107 105 108 @Override public boolean executeCommand() { 106 109 for (int i = 0; i < sequence.length; i++) { 107 boolean result = sequence[i].executeCommand(); 110 boolean result = false; 111 try { 112 result = sequence[i].executeCommand(); 113 } catch (AssertionError | Exception e) { 114 throw createReportedException(e, i); 115 } 108 116 if (!result && !continueOnError) { 109 117 undoCommands(i-1); 110 118 return false; … … 126 134 127 135 protected final void undoCommands(int start) { 128 136 for (int i = start; i >= 0; --i) { 129 sequence[i].undoCommand(); 137 try { 138 sequence[i].undoCommand(); 139 } catch (AssertionError | Exception e) { 140 throw createReportedException(e, i); 141 } 130 142 } 131 143 } 132 144 145 private ReportedException createReportedException(Throwable e, int i) { 146 ReportedException exception = new ReportedException(e); 147 exception.startSection("sequence_information"); 148 exception.put("sequence_name", getDescriptionText()); 149 exception.put("sequence_command", sequence[i].getDescriptionText()); 150 exception.put("sequence_index", i); 151 exception.put("sequence_commands", "[" + 152 Stream.of(sequence).map(o -> o.getClass().getCanonicalName()) 153 .map(Object::toString).collect(Collectors.joining(";")) 154 + "]"); 155 exception.put("sequence_commands_descriptions", "[" + 156 Stream.of(sequence).map(Command::getDescriptionText) 157 .collect(Collectors.joining(";")) 158 + "]"); 159 return exception; 160 } 161 133 162 @Override 134 163 public void undoCommand() { 135 164 // We probably aborted this halfway though the execution sequence because of a sub-command error.