fix: Suppress HFP profile rejection DBusError traceback

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-30 22:15:48 +00:00
parent 6c6c70c254
commit 2a02dc0f5a

14
main.py
View File

@@ -250,7 +250,21 @@ async def fetch_mqtt():
loop.create_task(process_mqtt(message))
def suppress_hfp_rejection_error(loop, context):
exception = context.get('exception')
if isinstance(exception, DBusError) and 'HFP profile not supported' in str(exception):
# This is the expected error from AuthorizeService, so we can suppress the traceback.
logging.debug('Suppressed expected DBusError for HFP rejection.')
return
# For all other exceptions, fall back to the default handler.
loop.default_exception_handler(context)
async def main():
loop = asyncio.get_running_loop()
loop.set_exception_handler(suppress_hfp_rejection_error)
global bus
bus = await MessageBus(bus_type=BusType.SYSTEM).connect()