Merge branch 'master' of git.labs.intellij.net:idea/community

This commit is contained in:
Alexey Pegov
2010-07-26 14:04:55 +04:00
3 changed files with 38 additions and 1 deletions
@@ -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;
@@ -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 extends Throwable> T findCause(Throwable e, Class<T> 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;
}
}
@@ -58,7 +58,7 @@ public class FutureResult<T> implements Future<T> {
private T doGet() throws ExecutionException {
Pair<Object, Boolean> 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;
}
}