Index: applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/CommandLine.java
===================================================================
--- applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/CommandLine.java	(revision 35937)
+++ applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/CommandLine.java	(revision 35942)
@@ -21,5 +21,4 @@
 import java.nio.file.StandardCopyOption;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.List;
@@ -47,4 +46,5 @@
 import org.openstreetmap.josm.gui.MainMenu;
 import org.openstreetmap.josm.gui.MapFrame;
+import org.openstreetmap.josm.gui.Notification;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
@@ -52,4 +52,5 @@
 import org.openstreetmap.josm.gui.layer.ImageryLayer;
 import org.openstreetmap.josm.gui.layer.Layer;
+import org.openstreetmap.josm.gui.util.GuiHelper;
 import org.openstreetmap.josm.gui.widgets.DisableShortcutsOnFocusGainedTextField;
 import org.openstreetmap.josm.io.GpxWriter;
@@ -497,9 +498,14 @@
             tp.process = builder.start();
         } catch (final IOException e) {
+            final String errorText;
             synchronized (debugstr) {
-                Logging.error(
-                        tr("Error executing the script:") + ' ' +
-                        debugstr.toString() + e.getMessage() + '\n' + Arrays.toString(e.getStackTrace()));
-            }
+                errorText = tr("Error executing the script:") + ' ' + debugstr + e.getMessage();
+            }
+            Logging.error(errorText);
+            Logging.error(e);
+            GuiHelper.runInEDT(() ->
+                new Notification(errorText).setIcon(JOptionPane.ERROR_MESSAGE).setDuration(Notification.TIME_LONG).show()
+            );
+            setMode(Mode.IDLE);
             return;
         }
Index: applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/LengthAction.java
===================================================================
--- applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/LengthAction.java	(revision 35937)
+++ applications/editors/josm/plugins/CommandLine/src/org/openstreetmap/josm/plugins/commandline/LengthAction.java	(revision 35942)
@@ -152,5 +152,5 @@
         drawStartPos = null;
         drawing = false;
-        exitMode();
+        // exitMode is called when we change to a different action. Do not call it here.
     }
 
