RuntimeModuleDescriptor (@NotNull RuntimeModuleId moduleId) { ResolveResult result = resolveModule(moduleId); RuntimeModuleDescriptor module = result.getResolvedModule(); if (module != null) { return module; } List<RuntimeModuleId> failedDependencyPath = result.getFailedDependencyPath(); String message; if (failedDependencyPath.size() == 1) { message = "Cannot find module '" + failedDependencyPath.get(0).getStringId() + "'"; } else { List<RuntimeModuleId> reversed = new ArrayList<>(failedDependencyPath.subList(0, failedDependencyPath.size() - 1)); Collections.reverse(reversed); message = "Cannot resolve module '" + moduleId.getStringId() + "': module '" + failedDependencyPath.get(failedDependencyPath.size() - 1).getStringId() + "' (" + reversed.stream().map(id -> " <- '" + id.getStringId() + "'").collect(Collectors.joining()).trim() + ") is not found"; } throw new MalformedRepositoryException(message); }