import asyncio async def coro_a(): await asyncio.sleep(1) raise ValueError("Error in Coro A") async def coro_b(): await asyncio.sleep(1) raise TypeError("Error in Coro B") async def coro_c(): await asyncio.sleep(1) raise IndexError("Error in Coro C") async def main(): results = await asyncio.gather( coro_a(), coro_b(), coro_c(), return_exceptions= True # renvoie les exceptions comme des résultats ) exceptions = [e for e in results if isinstance(e, Exception)] if exceptions: raise ExceptionGroup("errors", exceptions) if __name__ == "__main__": try: asyncio.run(main()) except* ValueError as ve_group: print(f"Value Error:", ve_group) except* TypeError as te_group: print(f"Type Error:", te_group) except* IndexError as ie_group: print(f"Index Error:", ie_group)