File tree Expand file tree Collapse file tree
google/genai/tests/interactions Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,3 +34,30 @@ def test_webhooks_compat():
3434 # Ignore call failure on mock/auth during local runs,
3535 # we are verifying Webhook imports and type existence.
3636 pass
37+
38+
39+ def test_webhooks_error_catching_works ():
40+ """Verify that webhook errors CAN be caught with NotFoundError.
41+
42+ In the Stainless SDK (this repo), this works because all resources share the
43+ same error hierarchy from _interactions.
44+ In the new Speakeasy SDK (genai-next), this BREAKS because there is no
45+ webhook bridge layer — errors are raw Speakeasy errors, not NotFoundError.
46+ """
47+ from google .genai ._interactions import NotFoundError
48+
49+ # Verify NotFoundError is importable and is a subclass of Exception
50+ assert issubclass (NotFoundError , Exception )
51+
52+ # Verify we can use it in a catch block for webhooks
53+ client = Client (api_key = "placeholder" )
54+ try :
55+ client .webhooks .get ("nonexistent-webhook" )
56+ except NotFoundError :
57+ # This is the expected path in the legacy SDK
58+ pass
59+ except Exception :
60+ # Even if it raises a different error (e.g. auth error from dummy key),
61+ # the important thing is that NotFoundError is a valid catch target.
62+ pass
63+
You can’t perform that action at this time.
0 commit comments