Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Reading and following these guidelines will help us make the contribution proces
* [Getting Started](#getting-started)
* [Making Changes](#making-changes)
* [Opening Issues](#opening-issues)
* [Submitting Pull Requests](#submitting-pull-requests) [Note: We are not accepting Pull Requests at this time!]
* [Submitting Pull Requests](#submitting-pull-requests)
* [Getting in Touch](#getting-in-touch)
* [Have a question or problem?](#have-a-question-or-problem)
* [Vulnerability Reporting](#vulnerability-reporting)
Expand Down
48 changes: 25 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ This is an autogenerated python SDK for OpenFGA. It provides a wrapper around th
- [Relationship Queries](#relationship-queries)
- [Check](#check)
- [Batch Check](#batch-check)
- [Client Batch Check](#client-batch-check)
- [Expand](#expand)
- [List Objects](#list-objects)
- [Streamed List Objects](#streamed-list-objects)
Expand Down Expand Up @@ -1283,6 +1284,30 @@ async def main():
```


### Error Handling

The SDK provides comprehensive error handling with detailed error information and convenient helper methods.

Key features:
- Operation context in error messages (e.g., `[write]`, `[check]`)
- Detailed error codes and messages from the API
- Helper methods for error categorization (`is_validation_error()`, `is_retryable()`, etc.)

```python
from openfga_sdk.exceptions import ApiException

try:
await client.write([tuple])
except ApiException as e:
print(f"Error: {e}") # [write] HTTP 400 type 'invalid_type' not found (validation_error) [request-id: abc-123]

if e.is_validation_error():
print(f"Validation error: {e.error_message}")
elif e.is_retryable():
print(f"Temporary error - retrying... (Request ID: {e.request_id})")
```


### API Endpoints

Class | Method | HTTP request | Description
Expand Down Expand Up @@ -1407,29 +1432,6 @@ Class | Method | HTTP request | Description

This SDK supports producing metrics that can be consumed as part of an [OpenTelemetry](https://opentelemetry.io/) setup. For more information, please see [the documentation](https://github.com/openfga/python-sdk/blob/main/docs/opentelemetry.md)

### Error Handling

The SDK provides comprehensive error handling with detailed error information and convenient helper methods.

Key features:
- Operation context in error messages (e.g., `[write]`, `[check]`)
- Detailed error codes and messages from the API
- Helper methods for error categorization (`is_validation_error()`, `is_retryable()`, etc.)

```python
from openfga_sdk.exceptions import ApiException

try:
await client.write([tuple])
except ApiException as e:
print(f"Error: {e}") # [write] HTTP 400 type 'invalid_type' not found (validation_error) [request-id: abc-123]

if e.is_validation_error():
print(f"Validation error: {e.error_message}")
elif e.is_retryable():
print(f"Temporary error - retrying... (Request ID: {e.request_id})")
```

## Contributing

See [CONTRIBUTING](./CONTRIBUTING.md) for details.
Expand Down
1 change: 1 addition & 0 deletions test/error_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
],
}


@pytest.mark.integration
@pytest.mark.asyncio
class TestErrorIntegration:
Expand Down