
Checking for cancellation by inspecting the string content of an exception (if "cancelled by user" in error_msg.lower():) is fragile and can lead to bugs if the error message changes.
It would be more robust to define and raise a specific CancellationError or ProcessingCancelledError exception. This allows for a more reliable try...except CancellationError: block, making the control flow clearer and less prone to breaking from changes in error messages.
Originally posted by @gemini-code-assist[bot] in #111 (comment)