handle index out of bounds errors

This commit is contained in:
ChrisColeTech
2025-03-11 20:07:21 -04:00
parent e5b2ab1515
commit 19f26ce0dc
2 changed files with 7 additions and 4 deletions
+6 -3
View File
@@ -180,12 +180,15 @@ class TextFileLineReader:
if mode == "index":
# Use the provided index directly
if index < 0 or index >= len(lines):
print(f"Invalid line index `{index}`. Using index 0.")
index = 0
print(f"Index `{index}` is out of bounds. Resetting to 0.")
index = 0 # Reset to 0 if out of bounds
line_text = lines[index]
else:
# Automatic mode: use the current_index and increment it
line_text = lines[self.current_index % len(lines)]
if self.current_index >= len(lines):
print("Reached the end of the file. Resetting to 0.")
self.current_index = 0 # Reset to 0 if at the end
line_text = lines[self.current_index]
self.current_index += 1 # Increment the index for the next run
return (line_text,)
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui-line-counter"
description = "This custom node package for ComfyUI is designed to streamline your workflow with powerful file-counting capabilities."
version = "1.0.6"
version = "1.0.7"
license = {file = "LICENSE"}
[project.urls]