diff --git a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java index bde320d72..f1a0494f1 100644 --- a/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java +++ b/vscode-extensions/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/ExceptionUtil.java @@ -33,6 +33,29 @@ public class ExceptionUtil { } return cause; } + + /** + * + * @param e + * @param toLookFor type of throwable to look for in the given throwable. + * @return the throwable instance of the given type, or null if nothing found. + */ + public static Throwable getThrowable(Throwable e, Class toLookFor) { + if (e.getClass().equals(toLookFor)) { + return e; + } + + Throwable cause = e; + Throwable parent = e.getCause(); + while (parent != null && parent != e) { + cause = parent; + parent = cause.getCause(); + if (cause.getClass().equals(toLookFor)) { + return cause; + } + } + return null; + } public static String getMessage(Throwable e) { // The message of nested exception is usually more interesting than the diff --git a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java index fede17366..75f651244 100644 --- a/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java +++ b/vscode-extensions/vscode-manifest-yaml/src/main/java/org/springframework/ide/vscode/manifest/yaml/AbstractCFHintsProvider.java @@ -50,9 +50,9 @@ public abstract class AbstractCFHintsProvider implements Provider