Summary
Error handling is inconsistent across different backends, making the code harder to understand and maintain.
Locations
Multiple files in src/proctap/backends/
Problem Examples
1. WindowsBackend - Swallows exceptions and returns empty bytes
# windows.py:124-128
if self._converter and data:
try:
data = self._converter.convert(data)
except Exception as e:
logger.error(f"Error converting audio format: {e}")
return b'' # Silent failure
2. LinuxBackend - Swallows exceptions and returns empty bytes
# linux.py:1353-1358
if self._converter and data:
try:
data = self._converter.convert(data)
except Exception as e:
logger.error(f"Error converting audio format: {e}")
return b'' # Silent failure
3. Core worker - Continues on exception
# core.py:218-222
try:
data = self._backend.read()
except Exception:
logger.exception("Error reading data from backend")
continue # Silently continues
4. PipeWireNative - Raises custom exceptions
# pipewire_native.py - Uses PipeWireError, PipeWireInitError, etc.
raise PipeWireStreamError(f"Failed to connect stream: {error_msg}")
Impact
- Hard to distinguish between "no data available" and "error occurred"
- Users cannot reliably detect and handle errors
- Logging may be the only indication of issues
Suggested Fix
- Define consistent error handling strategy
- Consider raising exceptions for unrecoverable errors
- Return sentinel values (None vs b'') consistently:
- None = no data available (normal)
- b'' = empty data (normal)
- Exception = actual error
Labels
readability, enhancement
Summary
Error handling is inconsistent across different backends, making the code harder to understand and maintain.
Locations
Multiple files in src/proctap/backends/
Problem Examples
1. WindowsBackend - Swallows exceptions and returns empty bytes
2. LinuxBackend - Swallows exceptions and returns empty bytes
3. Core worker - Continues on exception
4. PipeWireNative - Raises custom exceptions
Impact
Suggested Fix
Labels
readability, enhancement