/** * Creates an abbreviated representation of the specified exception. * <p> * The current implementation of this is to return the {@link Class#getSimpleName() simple class name} * of {@code e}. If {@code e} has a {@link Throwable#getMessage() message}, then {@code ": "} is * added, followed by that message. This is repeated for each {@link Throwable#getCause() cause} in * {@code e}'s exception chain, with newlines in between, until they are all exhausted or the * {@link com.atlassian.scheduler.status.RunDetails#MAXIMUM_MESSAGE_LENGTH} has been reached. This is just a rough guess at what * is moderately likely to be useful information. * </p> * * @param e the exception to convert into an abbreviated troubleshooting message * @return the message */ private static String toMessage(final Throwable e) { final StringBuilder message = new StringBuilder(MAXIMUM_MESSAGE_LENGTH); appendShortForm(message, e); Throwable cause = e.getCause(); while (message.length() < MAXIMUM_MESSAGE_LENGTH && cause != null) { message.append('\n'); appendShortForm(message, cause); cause = cause.getCause(); } if (message.length() > MAXIMUM_MESSAGE_LENGTH) { message.setLength(MAXIMUM_MESSAGE_LENGTH); } return message.toString(); }