fix(main.py): handle argument parsing errors and improve error messages

This commit is contained in:
2025-09-04 21:02:17 +02:00
parent 6e9bb9ad8e
commit 6c8a5dad8e

View File

@@ -339,6 +339,7 @@ class VideoEditor:
# Apply brightness/contrast first (to original frame for best quality) # Apply brightness/contrast first (to original frame for best quality)
processed_frame = self.apply_brightness_contrast(processed_frame) processed_frame = self.apply_brightness_contrast(processed_frame)
# Apply crop # Apply crop
if self.crop_rect: if self.crop_rect:
x, y, w, h = self.crop_rect x, y, w, h = self.crop_rect
@@ -1420,17 +1421,28 @@ def main():
"video", help="Path to video file or directory containing videos" "video", help="Path to video file or directory containing videos"
) )
args = parser.parse_args() try:
args = parser.parse_args()
except SystemExit as e:
# If launched from context menu without arguments, this might fail
input(f"Argument parsing failed. Press Enter to exit...")
return
if not os.path.exists(args.video): if not os.path.exists(args.video):
print(f"Error: {args.video} does not exist") error_msg = f"Error: {args.video} does not exist"
print(error_msg)
input("Press Enter to exit...") # Keep window open in context menu
sys.exit(1) sys.exit(1)
try: try:
editor = VideoEditor(args.video) editor = VideoEditor(args.video)
editor.run() editor.run()
except Exception as e: except Exception as e:
print(f"Error: {e}") error_msg = f"Error initializing video editor: {e}"
print(error_msg)
import traceback
traceback.print_exc() # Full error trace for debugging
input("Press Enter to exit...") # Keep window open in context menu
sys.exit(1) sys.exit(1)