diff --git a/examples/rpc.py b/examples/rpc.py index a79877f0..c7ef69d4 100644 --- a/examples/rpc.py +++ b/examples/rpc.py @@ -35,16 +35,16 @@ async def main(): print("Error:", error) try: - print("\n\nRunning math example...") - await perform_square_root(callers_room) - await asyncio.sleep(2) - await perform_quantum_hypergeometric_series(callers_room) + print("\n\nRunning error handling example...") + await perform_divide(callers_room) except Exception as error: print("Error:", error) try: - print("\n\nRunning divide by zero example...") - await perform_divide(callers_room) + print("\n\nRunning math example...") + await perform_square_root(callers_room) + await asyncio.sleep(2) + await perform_quantum_hypergeometric_series(callers_room) except Exception as error: print("Error:", error) @@ -99,9 +99,6 @@ async def divide_method( divisor = json_data["divisor"] print(f"[Math Genius] {caller.identity} wants to divide {dividend} by {divisor}.") - if divisor == 0: - raise ValueError("Cannot divide by zero!") - result = dividend / divisor return json.dumps({"result": result}) @@ -159,7 +156,7 @@ async def perform_quantum_hypergeometric_series(room: rtc.Room): async def perform_divide(room: rtc.Room): - print("[Caller] Let's try to divide by zero!") + print("[Caller] Let's divide 10 by 0.") try: response = await room.local_participant.perform_rpc( "math-genius", "divide", json.dumps({"dividend": 10, "divisor": 0}) @@ -168,7 +165,7 @@ async def perform_divide(room: rtc.Room): print(f"[Caller] The result is {parsed_response['result']}") except rtc.RpcError as error: if error.code == rtc.RpcError.ErrorCode.APPLICATION_ERROR: - print("[Caller] Aww something went wrong over there, too bad!") + print("[Caller] Aww something went wrong with that one, lets try something else.") else: print(f"[Caller] RPC call failed with unexpected RpcError: {error}") except Exception as error: diff --git a/livekit-rtc/livekit/rtc/participant.py b/livekit-rtc/livekit/rtc/participant.py index 3f1f0f97..5137a30b 100644 --- a/livekit-rtc/livekit/rtc/participant.py +++ b/livekit-rtc/livekit/rtc/participant.py @@ -376,7 +376,7 @@ async def _handle_rpc_method_invocation( response_error = error except Exception as error: print( - f"Uncaught error returned by RPC handler for {method}. Returning UNCAUGHT_ERROR instead.", + f"Uncaught error returned by RPC handler for {method}. Returning APPLICATION_ERROR instead.", error, ) response_error = RpcError._built_in(RpcError.ErrorCode.APPLICATION_ERROR) diff --git a/livekit-rtc/rust-sdks b/livekit-rtc/rust-sdks index b37ef6eb..089b748d 160000 --- a/livekit-rtc/rust-sdks +++ b/livekit-rtc/rust-sdks @@ -1 +1 @@ -Subproject commit b37ef6eb5af96c0cf77704e048fcd385d64b8b61 +Subproject commit 089b748d3efb3fac2e291f03a234e73676b0dfa2