From 222e2cb2233b4edc0270be36d41c6c9bf5f0491e Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 26 Jul 2010 11:17:47 +0400 Subject: [PATCH 1/2] CIDR-debugger: error reporting refactored --- .../src/com/intellij/util/ExceptionUtil.java | 36 +++++++++++++++++++ .../util/concurrency/FutureResult.java | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 platform/util/src/com/intellij/util/ExceptionUtil.java diff --git a/platform/util/src/com/intellij/util/ExceptionUtil.java b/platform/util/src/com/intellij/util/ExceptionUtil.java new file mode 100644 index 000000000000..87723dad03c6 --- /dev/null +++ b/platform/util/src/com/intellij/util/ExceptionUtil.java @@ -0,0 +1,36 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.util; + +public class ExceptionUtil { + public static Throwable getRootCause(Throwable e) { + while (true) { + if (e.getCause() == null) return e; + e = e.getCause(); + } + } + + public static T findCause(Throwable e, Class klass) { + while (e != null && !klass.isInstance(e)) { + e = e.getCause(); + } + return (T)e; + } + + public static boolean causedBy(Throwable e, Class klass) { + return findCause(e, klass) != null; + } +} diff --git a/platform/util/src/com/intellij/util/concurrency/FutureResult.java b/platform/util/src/com/intellij/util/concurrency/FutureResult.java index 356ec5845238..0f115e660b16 100644 --- a/platform/util/src/com/intellij/util/concurrency/FutureResult.java +++ b/platform/util/src/com/intellij/util/concurrency/FutureResult.java @@ -58,7 +58,7 @@ public class FutureResult implements Future { private T doGet() throws ExecutionException { Pair pair = myValue.get(); - if (!pair.second) throw new ExecutionException((Throwable)pair.first); + if (!pair.second) throw new ExecutionException(((Throwable)pair.first).getMessage(), (Throwable)pair.first); return (T)pair.first; } } From d73223c48d9cfc5918bc767902a73c9e3947918b Mon Sep 17 00:00:00 2001 From: Anton Makeev Date: Mon, 26 Jul 2010 13:50:11 +0400 Subject: [PATCH 2/2] compilation fix --- .../codeInsight/completion/JavaSmartCompletionContributor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java index e1c7d5cbba5d..32808d2f7520 100644 --- a/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java +++ b/java/java-impl/src/com/intellij/codeInsight/completion/JavaSmartCompletionContributor.java @@ -16,6 +16,7 @@ package com.intellij.codeInsight.completion; import com.intellij.codeInsight.*; +import com.intellij.codeInsight.ExceptionUtil; import com.intellij.codeInsight.lookup.*; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.util.Computable;