String (@NotNull Throwable error) { // run through stacktrace and see if it has frames pointing to specific groovy script StackTraceElement scriptFrame = ContainerUtil.find(error.getStackTrace(), (element -> { String fileName = element.getFileName(); return fileName != null && (fileName.endsWith("." + EXTENSION) || fileName.endsWith("." + KOTLIN_DSL_SCRIPT_EXTENSION)); })); if (scriptFrame != null) { return "Build file '" + scriptFrame.getFileName() + "' line: " + scriptFrame.getLineNumber(); } return null; }