Fixed bug where no-targets error still contains appended information
This commit is contained in:
@@ -68,6 +68,17 @@ public class ExceptionUtil {
|
|||||||
return "An error occurred: " + getSimpleError(e);
|
return "An error occurred: " + getSimpleError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getMessageNoAppendedInformation(Throwable e) {
|
||||||
|
Throwable deepestCause = ExceptionUtil.getDeepestCause(e);
|
||||||
|
String msg = deepestCause != null ? deepestCause.getMessage() : null;
|
||||||
|
|
||||||
|
if (StringUtil.hasText(msg)) {
|
||||||
|
return msg;
|
||||||
|
} else {
|
||||||
|
return "An error occurred: " + getSimpleError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getSimpleError(Throwable e) {
|
public static String getSimpleError(Throwable e) {
|
||||||
return e.getClass().getSimpleName();
|
return e.getClass().getSimpleName();
|
||||||
|
|||||||
@@ -186,12 +186,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
|
|||||||
|
|
||||||
// If value parse exception, do not append any additional information
|
// If value parse exception, do not append any additional information
|
||||||
if (e instanceof ValueParseException) {
|
if (e instanceof ValueParseException) {
|
||||||
String msg = e.getMessage();
|
return ExceptionUtil.getMessageNoAppendedInformation(e);
|
||||||
if (StringUtil.hasText(msg)) {
|
|
||||||
return msg;
|
|
||||||
} else {
|
|
||||||
return "An error occurred: " + getSimpleError(e);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return ExceptionUtil.getMessage(e);
|
return ExceptionUtil.getMessage(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,14 +48,19 @@ public abstract class AbstractCFHintsProvider implements Callable<Collection<YVa
|
|||||||
hints.addAll(resolvedHints);
|
hints.addAll(resolvedHints);
|
||||||
}
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
// Convert any non "no-target" errors to something readable. The
|
// Convert any error into something readable to the user as it may
|
||||||
// "no-target" errors
|
// appear in the content assist
|
||||||
// are generated by the target provider so they should be propagated
|
// UI. Do NOT wrap the original exception as the framework may look
|
||||||
// as is without further
|
// for the deepest cause when
|
||||||
// transformation
|
// resolving the error message. Instead, log the full error, and
|
||||||
|
// only throw a
|
||||||
|
// new exception with a "nicer" message
|
||||||
Throwable noTargetsError = ExceptionUtil.getThrowable(e, NoTargetsException.class);
|
Throwable noTargetsError = ExceptionUtil.getThrowable(e, NoTargetsException.class);
|
||||||
if (noTargetsError != null) {
|
if (noTargetsError != null) {
|
||||||
throw new ValueParseException(ExceptionUtil.getMessage(noTargetsError));
|
// Do not log the no-targets exception as it may be encountered
|
||||||
|
// frequently
|
||||||
|
// if a user does not have a CF client installed
|
||||||
|
throw new ValueParseException(ExceptionUtil.getMessageNoAppendedInformation(noTargetsError));
|
||||||
} else {
|
} else {
|
||||||
// Log any other error
|
// Log any other error
|
||||||
logger.log(Level.SEVERE, ExceptionUtil.getMessage(e), e);
|
logger.log(Level.SEVERE, ExceptionUtil.getMessage(e), e);
|
||||||
|
|||||||
Reference in New Issue
Block a user