Skip to content

fix(errors): add typed exceptions and capture trailing metadata#85

Merged
zeevdr merged 3 commits into
mainfrom
feat/typed-errors-54
May 20, 2026
Merged

fix(errors): add typed exceptions and capture trailing metadata#85
zeevdr merged 3 commits into
mainfrom
feat/typed-errors-54

Conversation

@zeevdr
Copy link
Copy Markdown
Member

@zeevdr zeevdr commented May 20, 2026

Summary

  • Closes gaps in the gRPC status code map so callers can catch TimeoutError, ResourceExhaustedError, CancelledError, and UnimplementedError by type instead of inspecting .code.
  • Exposes trailing_metadata on DecreeError so callers can inspect raw gRPC trailers (e.g., google.rpc.ErrorInfo).
  • Parses google.rpc.RetryInfo from grpc-status-details-bin and surfaces the result as retry_after: timedelta | None, making rate-limit and deadline back-off trivial for callers.

Test plan

  • New mapping tests for all four added status codes
  • trailing_metadata captured and accessible on the exception
  • retry_after correctly parsed from packed RetryInfo (seconds + nanos precision)
  • No retry_after when metadata is absent or contains no RetryInfo
  • All 222 existing tests continue to pass; errors.py at 100% coverage

Closes #54

Add TimeoutError (DEADLINE_EXCEEDED), ResourceExhaustedError,
CancelledError, and UnimplementedError to the gRPC status code map.

DecreeError now captures trailing_metadata from the RpcError and
exposes a retry_after timedelta parsed from google.rpc.RetryInfo
packed in the grpc-status-details-bin trailer.

Closes #54

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr added this to the Beta Readiness milestone May 20, 2026
@zeevdr zeevdr added size: S Quick win — a few hours or less priority: P1 Current milestone work labels May 20, 2026
…edError

Co-Authored-By: Claude <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented May 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…leapis-common-protos)

Co-Authored-By: Claude <noreply@anthropic.com>
@zeevdr zeevdr merged commit 2ab4ecc into main May 20, 2026
12 checks passed
@zeevdr zeevdr deleted the feat/typed-errors-54 branch May 20, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: P1 Current milestone work size: S Quick win — a few hours or less

Projects

None yet

Development

Successfully merging this pull request may close these issues.

errors.py: add typed exceptions for DEADLINE_EXCEEDED, RESOURCE_EXHAUSTED, CANCELLED, UNIMPLEMENTED; expose trailing metadata

1 participant