/** * Creates a ParsingError object with the root cause message from the given cause if available. * * @param cause A cause if available. * * @return A ParsingError representing this cause. */ public static ParsingError makeError(Throwable cause) { String message = ExceptionUtils.getRootCauseMessage(cause); message = message.isEmpty() ? GENERIC_JSON_ERROR : message; return new ParsingError(message, singletonList(GENERIC_JSON_RESOLUTION)); }
/** * Creates a ParsingError object with the original query string and the root cause message from the given cause. * * @param cause A cause. * @param queryString The original query. * * @return A ParsingError representing this cause. */ public static ParsingError makeError(RuntimeException cause, String queryString) { String message = ExceptionUtils.getRootCauseMessage(cause); message = message.isEmpty() ? "" : message; return new ParsingError(GENERIC_JSON_ERROR + ":\n" + queryString + "\n" + message, singletonList(GENERIC_JSON_RESOLUTION)); } }