Index: trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java	(revision 15069)
+++ trunk/src/org/openstreetmap/josm/actions/SessionLoadAction.java	(revision 15070)
@@ -22,4 +22,5 @@
 import org.openstreetmap.josm.gui.HelpAwareOptionPane;
 import org.openstreetmap.josm.gui.MainApplication;
+import org.openstreetmap.josm.gui.Notification;
 import org.openstreetmap.josm.gui.PleaseWaitRunnable;
 import org.openstreetmap.josm.gui.layer.Layer;
@@ -37,4 +38,5 @@
 import org.openstreetmap.josm.tools.Logging;
 import org.openstreetmap.josm.tools.Utils;
+import org.openstreetmap.josm.tools.bugreport.ReportedException;
 
 /**
@@ -138,8 +140,5 @@
                     if (canceled)
                         return;
-                    // NoteImporter directly loads notes into current note layer
-                    if (!MainApplication.getLayerManager().containsLayer(l)) {
-                        MainApplication.getLayerManager().addLayer(l);
-                    }
+                    addLayer(l);
                 }
                 if (active != null) {
@@ -150,4 +149,27 @@
                 }
             }
+        }
+
+        /**
+         * Tries to add a new layer.
+         * @param l layer to add
+         * @return {@code true} if layer has been added, {@code false} if it wasn't needed or if an error occurred
+         */
+        static boolean addLayer(Layer l) {
+            // NoteImporter directly loads notes into current note layer
+            if (!MainApplication.getLayerManager().containsLayer(l)) {
+                try {
+                    MainApplication.getLayerManager().addLayer(l);
+                } catch (ReportedException e) {
+                    Logging.error(e);
+                    new Notification(tr("Unable to add layer ''{0}'': {1}", l.getName(), e.getMessage()))
+                        .setIcon(JOptionPane.ERROR_MESSAGE).setDuration(Notification.TIME_LONG).show();
+                    if (MainApplication.getLayerManager().containsLayer(l)) {
+                        MainApplication.getLayerManager().removeLayer(l);
+                    }
+                    return false;
+                }
+            }
+            return true;
         }
 
Index: trunk/src/org/openstreetmap/josm/io/session/SessionReader.java
===================================================================
--- trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 15069)
+++ trunk/src/org/openstreetmap/josm/io/session/SessionReader.java	(revision 15070)
@@ -565,5 +565,5 @@
                         throw new IllegalStateException("Importer " + imp + " returned null for " + support);
                     }
-                } catch (IllegalDataException | IllegalStateException | IOException ex) {
+                } catch (IllegalDataException | IllegalArgumentException | IllegalStateException | IOException ex) {
                     exception = ex;
                 }
@@ -704,5 +704,5 @@
     public void loadSession(File sessionFile, boolean zip, ProgressMonitor progressMonitor) throws IllegalDataException, IOException {
         try (InputStream josIS = createInputStream(sessionFile, zip)) {
-            loadSession(josIS, sessionFile.toURI(), zip, progressMonitor != null ? progressMonitor : NullProgressMonitor.INSTANCE);
+            loadSession(josIS, sessionFile.toURI(), zip, progressMonitor);
         }
     }
@@ -737,5 +737,15 @@
     }
 
-    private void loadSession(InputStream josIS, URI sessionFileURI, boolean zip, ProgressMonitor progressMonitor)
+    /**
+     * Loads session from the given input stream.
+     * @param josIS session stream to load
+     * @param zip {@code true} if it's a zipped session (.joz)
+     * @param sessionFileURI URI of the underlying session file
+     * @param progressMonitor progress monitor
+     * @throws IllegalDataException if invalid data is detected
+     * @throws IOException if any I/O error occurs
+     * @since xxx
+     */
+    public void loadSession(InputStream josIS, URI sessionFileURI, boolean zip, ProgressMonitor progressMonitor)
             throws IOException, IllegalDataException {
 
@@ -744,5 +754,5 @@
 
         try {
-            parseJos(XmlUtils.parseSafeDOM(josIS), progressMonitor);
+            parseJos(XmlUtils.parseSafeDOM(josIS), progressMonitor != null ? progressMonitor : NullProgressMonitor.INSTANCE);
         } catch (SAXException e) {
             throw new IllegalDataException(e);
Index: trunk/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java	(revision 15070)
+++ trunk/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java	(revision 15070)
@@ -0,0 +1,37 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.actions;
+
+import static org.junit.Assert.assertFalse;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.openstreetmap.josm.data.imagery.ImageryInfo;
+import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
+import org.openstreetmap.josm.gui.layer.TMSLayer;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+/**
+ * Unit tests for class {@link SessionLoadAction}.
+ */
+public class SessionLoadActionTest {
+
+    /**
+     * Setup test.
+     */
+    @Rule
+    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+    public JOSMTestRules test = new JOSMTestRules().main().projection();
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17702">Bug #17702</a>.
+     */
+    @Test
+    public void testTicket17702() {
+        assertFalse(SessionLoadAction.Loader.addLayer(new TMSLayer(new ImageryInfo(
+                "Bing Карта (GLOBALCITY)",
+                "http://ecn.dynamic.t{switch:1,2,3}.tiles.virtualearth.net/comp/ch/{$q}?mkt=en-us&it=G,VE,BX,L,LA&shading=hill&og=2&n=z",
+                ImageryType.TMS.getTypeString(), null, null))));
+    }
+}
Index: trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java	(revision 15069)
+++ trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java	(revision 15070)
@@ -6,6 +6,9 @@
 import static org.junit.Assert.assertTrue;
 
+import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
 
@@ -154,3 +157,35 @@
         assertEquals(174, layer.getNoteData().getNotes().size());
     }
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17701">Bug #17701</a>.
+     * @throws Exception if an error occurs
+     */
+    @Test
+    public void testTicket17701() throws Exception {
+        try (InputStream in = new ByteArrayInputStream(("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
+                "<josm-session version=\"0.1\">\n" +
+                "    <layers active=\"1\">\n" +
+                "        <layer index=\"1\" name=\"GPS-треки OpenStreetMap\" type=\"imagery\" version=\"0.1\" visible=\"true\">\n" +
+                "            <id>osm-gps</id>\n" +
+                "            <type>tms</type>\n" +
+                "            <url>https://{switch:a,b,c}.gps-tile.openstreetmap.org/lines/{zoom}/{x}/{y}.png</url>\n" +
+                "            <attribution-text>© OpenStreetMap contributors</attribution-text>\n" +
+                "            <attribution-url>https://www.openstreetmap.org/copyright</attribution-url>\n" +
+                "            <max-zoom>20</max-zoom>\n" +
+                "            <cookies/>\n" +
+                "            <description>Общедоступные GPS-треки, загруженные на OpenStreetMap.</description>\n" +
+                "            <valid-georeference>true</valid-georeference>\n" +
+                "            <overlay>true</overlay>\n" +
+                "            <show-errors>true</show-errors>\n" +
+                "            <automatic-downloading>true</automatic-downloading>\n" +
+                "            <automatically-change-resolution>true</automatically-change-resolution>\n" +
+                "        </layer>\r\n" +
+                "    </layers>\n" +
+                "</josm-session>").getBytes(StandardCharsets.UTF_8))) {
+            SessionReader reader = new SessionReader();
+            reader.loadSession(in, null, false, null);
+            assertTrue(reader.getLayers().isEmpty());
+        }
+    }
 }
