mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
platform: replace more usages of RuntimeException by ExtensionInstantiationException in extensions module
This is needed to ensure that problems with extensions in plugins will be reported as plugin problems, not core problems (IDEA-201589). GitOrigin-RevId: e6dd8a7cce15c1ca01e9b6f23497f55b4c7d6f50
This commit is contained in:
committed by
intellij-monorepo-bot
parent
96b435d8d0
commit
cb0b790580
@@ -17,9 +17,20 @@ package com.intellij.openapi.extensions;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This exception is thrown if there is a critical problem with some loaded extension. Use this exception inside 'intellij.platform.extensions'
|
||||
* module only, in other parts of IntelliJ Platform and its plugins use {@link com.intellij.diagnostic.PluginException#createByClass} instead.
|
||||
*
|
||||
* @see com.intellij.openapi.extensions.ExtensionInstantiationException
|
||||
*/
|
||||
public class ExtensionException extends RuntimeException{
|
||||
private final Class<?> myExtensionClass;
|
||||
|
||||
public ExtensionException(@NotNull String message, @NotNull Class<?> extensionClass) {
|
||||
super(message);
|
||||
myExtensionClass = extensionClass;
|
||||
}
|
||||
|
||||
public ExtensionException(@NotNull Class<?> extensionClass) {
|
||||
super(extensionClass.getCanonicalName());
|
||||
|
||||
|
||||
+2
-2
@@ -198,7 +198,7 @@ public abstract class ExtensionPointImpl<T> implements ExtensionPoint<T>, Iterab
|
||||
if (adapter != null) {
|
||||
message += ". It came from " + adapter;
|
||||
}
|
||||
throw new RuntimeException(message);
|
||||
throw new ExtensionException(message, extension.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -788,7 +788,7 @@ public abstract class ExtensionPointImpl<T> implements ExtensionPoint<T>, Iterab
|
||||
myExtensionClass = extensionClass = extClass;
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new ExtensionInstantiationException(e, myDescriptor);
|
||||
}
|
||||
}
|
||||
return extensionClass;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.util;
|
||||
|
||||
import com.intellij.openapi.diagnostic.ControlFlowException;
|
||||
import com.intellij.openapi.extensions.ExtensionInstantiationException;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.extensions.KeyedFactoryEPBean;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
import com.intellij.util.ExceptionUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -71,7 +72,7 @@ public abstract class KeyedExtensionFactory<T, KeyT> {
|
||||
throw e;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new ExtensionInstantiationException(e, epBean.getPluginDescriptor());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@@ -104,14 +105,18 @@ public abstract class KeyedExtensionFactory<T, KeyT> {
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
ExceptionUtil.rethrowUnchecked(e.getCause());
|
||||
throw new RuntimeException(e);
|
||||
Throwable t = e.getCause();
|
||||
if (t instanceof ControlFlowException && t instanceof RuntimeException) throw (RuntimeException)t;
|
||||
throw new ExtensionInstantiationException(e, epBean.getPluginDescriptor());
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
throw e;
|
||||
if (e instanceof ControlFlowException) {
|
||||
throw e;
|
||||
}
|
||||
throw new ExtensionInstantiationException(e, epBean.getPluginDescriptor());
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new ExtensionInstantiationException(e, epBean.getPluginDescriptor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user