RUBY-18140 Markdown setting plugin: Unable to save settings Popup
authorVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 1 Jul 2016 12:38:34 +0000 (14:38 +0200)
committerVladimir Krivosheev <vladimir.krivosheev@jetbrains.com>
Fri, 1 Jul 2016 12:41:09 +0000 (14:41 +0200)
Include component name into the error message

platform/configuration-store-impl/src/ComponentStoreImpl.kt
platform/configuration-store-impl/src/StateStorageManagerImpl.kt

index 9ca3018bfbf323749f28639ce70767c9c67c3eaa..34e98b832d18300df56a37c0a957f073ce1e1ab7 100644 (file)
@@ -87,23 +87,26 @@ abstract class ComponentStoreImpl : IComponentStore {
     }
 
     val componentNameIfStateExists: String?
+    var componentName = ""
     try {
       componentNameIfStateExists = if (component is PersistentStateComponent<*>) {
         val stateSpec = StoreUtil.getStateSpec(component)
-        doAddComponent(stateSpec.name, component)
+        componentName = stateSpec.name
+        doAddComponent(componentName, component)
         @Suppress("UNCHECKED_CAST")
         initPersistentComponent(stateSpec, component as PersistentStateComponent<Any>, null, false)
       }
       else {
+        componentName = ComponentManagerImpl.getComponentName(component)
         @Suppress("DEPRECATION")
-        initJdomExternalizable(component as JDOMExternalizable)
+        initJdomExternalizable(component as JDOMExternalizable, componentName)
       }
     }
     catch (e: ProcessCanceledException) {
       throw e
     }
     catch (e: Exception) {
-      LOG.error(e)
+      LOG.error("Cannot init ${componentName} component state", e)
       return
     }
 
@@ -213,8 +216,7 @@ abstract class ComponentStoreImpl : IComponentStore {
     return errors
   }
 
-  private fun initJdomExternalizable(@Suppress("DEPRECATION") component: JDOMExternalizable): String? {
-    val componentName = ComponentManagerImpl.getComponentName(component)
+  private fun initJdomExternalizable(@Suppress("DEPRECATION") component: JDOMExternalizable, componentName: String): String? {
     doAddComponent(componentName, component)
 
     if (loadPolicy != StateLoadPolicy.LOAD) {
index d0372b28055a0a7d3c89794d653da8ac161d49ab..4db7f47da0ec58607f1c5f57ebeb0146f341c2fb 100644 (file)
@@ -132,8 +132,11 @@ open class StateStorageManagerImpl(private val rootTagName: String,
     }
   }
 
-  override final fun getStateStorage(storageSpec: Storage) = getOrCreateStorage(storageSpec.path, storageSpec.roamingType,
-          JavaAnnotationHelperForKotlin.getStorageClass(storageSpec), JavaAnnotationHelperForKotlin.getStateSplitterClass(storageSpec))
+  override final fun getStateStorage(storageSpec: Storage): StateStorage {
+    return getOrCreateStorage(storageSpec.path, storageSpec.roamingType,
+                              JavaAnnotationHelperForKotlin.getStorageClass(storageSpec),
+                              JavaAnnotationHelperForKotlin.getStateSplitterClass(storageSpec))
+  }
 
   protected open fun normalizeFileSpec(fileSpec: String): String {
     val path = FileUtilRt.toSystemIndependentName(fileSpec)
@@ -146,6 +149,10 @@ open class StateStorageManagerImpl(private val rootTagName: String,
                          storageClass: Class<out StateStorage> = StateStorage::class.java,
                          @Suppress("DEPRECATION") stateSplitter: Class<out StateSplitter> = StateSplitterEx::class.java): StateStorage {
     val normalizedCollapsedPath = normalizeFileSpec(collapsedPath)
+    if (normalizedCollapsedPath.isEmpty()) {
+      throw Exception("Normalized path is empty, raw path '$collapsedPath'")
+    }
+
     val key = if (storageClass == StateStorage::class.java) normalizedCollapsedPath else storageClass.name
     storageLock.withLock {
       var storage = storages[key]