Skip to content

Narrow exception handling and add logging for torchcodec fallback#43

Closed
Copilot wants to merge 3 commits intofeat/shard-from-audiofrom
copilot/sub-pr-40-again
Closed

Narrow exception handling and add logging for torchcodec fallback#43
Copilot wants to merge 3 commits intofeat/shard-from-audiofrom
copilot/sub-pr-40-again

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 10, 2026

Addresses review feedback on exception handling when importing torchcodec.decoders.AudioDecoder. The broad Exception catch was silently swallowing unrelated errors (internal bugs, environment issues) and making failures harder to diagnose.

Changes:

  • Catch specific exceptions (ImportError, OSError, RuntimeError) instead of broad Exception
  • Log warning with exception details when falling back to torchaudio-based decoder
try:
    from torchcodec.decoders import AudioDecoder
except (ImportError, OSError, RuntimeError) as e:
    logger.warning("Failed to import torchcodec AudioDecoder, falling back to torchaudio: %s", e)
    AudioDecoder = CompatAudioDecoder

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits February 10, 2026 23:55
Co-authored-by: tlebryk <43556997+tlebryk@users.noreply.github.com>
Co-authored-by: tlebryk <43556997+tlebryk@users.noreply.github.com>
Copilot AI changed the title [WIP] Update audio implementation based on feedback Narrow exception handling and add logging for torchcodec fallback Feb 10, 2026
Copilot AI requested a review from tlebryk February 10, 2026 23:57
@tlebryk tlebryk closed this Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants