String (@NotNull Throwable error) { String errorToString = error.toString(); if (errorToString.contains("LocationAwareException")) { // LocationAwareException is never passed, but converted into a PlaceholderException // that has the toString value of the original LocationAwareException. String location = error.getMessage(); if (location != null && (location.startsWith("Build file '") || location.startsWith("Settings file '"))) { // Only the first line contains the location of the error. Discard the rest. String[] lines = splitByLines(location); return lines.length > 0 ? lines[0] : null; } } return null; }