Skip to content

feat: add grpcutil.AuthzedError to catch sync and async gRPC errors#340

Open
ivanauth wants to merge 2 commits into
authzed:mainfrom
ivanauth:feat/issue-14-unified-exception
Open

feat: add grpcutil.AuthzedError to catch sync and async gRPC errors#340
ivanauth wants to merge 2 commits into
authzed:mainfrom
ivanauth:feat/issue-14-unified-exception

Conversation

@ivanauth

@ivanauth ivanauth commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #14.

The sync client raises grpc.RpcError and the async client raises
grpc.aio.AioRpcError. This adds a single name, grpcutil.AuthzedError,
that catches both:

from grpcutil import AuthzedError
try:
    client.CheckPermission(...)
except AuthzedError as err:
    ...

It's a thin alias for grpc.RpcError, which works because
grpc.aio.AioRpcError already subclasses grpc.RpcError - so one
except AuthzedError covers either client. Adds a test asserting both
error types are caught.

Note: except grpc.RpcError already catches both today; this just gives
the SDK a discoverable, branded name for it, as requested in the issue.

ivanauth added 2 commits June 16, 2026 19:02
…authzed#14)

The previous AuthzedError subclassed Exception and was never raised, so
'except AuthzedError' caught nothing. grpc.aio.AioRpcError already subclasses
grpc.RpcError, so alias AuthzedError to grpc.RpcError; a single except now
catches errors from both the sync and async clients. Adds a regression test.
@ivanauth
ivanauth requested a review from a team as a code owner July 9, 2026 01:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrap gRPC Exceptions

1 participant