|
7 | 7 | </a>
|
8 | 8 | </div>
|
9 | 9 |
|
10 |
| - |
11 |
| -## 🏗 **Welcome to your new SDK!** 🏗 |
12 |
| - |
13 |
| -It has been generated successfully based on your OpenAPI spec. However, it is not yet ready for production use. Here are some next steps: |
14 |
| -- [ ] 🛠 Make your SDK feel handcrafted by [customizing it](https://www.speakeasyapi.dev/docs/customize-sdks) |
15 |
| -- [ ] ♻️ Refine your SDK quickly by iterating locally with the [Speakeasy CLI](https://github.com/speakeasy-api/speakeasy) |
16 |
| -- [ ] 🎁 Publish your SDK to package managers by [configuring automatic publishing](https://www.speakeasyapi.dev/docs/productionize-sdks/publish-sdks) |
17 |
| -- [ ] ✨ When ready to productionize, delete this section from the README |
18 |
| - |
19 | 10 | <!-- Start Summary [summary] -->
|
20 | 11 | ## Summary
|
21 | 12 |
|
@@ -65,7 +56,15 @@ and standard method from web, mobile and desktop applications.
|
65 | 56 | >
|
66 | 57 | > Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.
|
67 | 58 |
|
68 |
| -The SDK can be installed with either *pip* or *poetry* package managers. |
| 59 | +The SDK can be installed with *uv*, *pip*, or *poetry* package managers. |
| 60 | + |
| 61 | +### uv |
| 62 | + |
| 63 | +*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities. |
| 64 | + |
| 65 | +```bash |
| 66 | +uv add formance-sdk-python |
| 67 | +``` |
69 | 68 |
|
70 | 69 | ### PIP
|
71 | 70 |
|
@@ -153,7 +152,7 @@ with SDK(
|
153 | 152 |
|
154 | 153 | </br>
|
155 | 154 |
|
156 |
| -The same SDK client can also be used to make asychronous requests by importing asyncio. |
| 155 | +The same SDK client can also be used to make asynchronous requests by importing asyncio. |
157 | 156 | ```python
|
158 | 157 | # Asynchronous Example
|
159 | 158 | import asyncio
|
@@ -563,26 +562,18 @@ with SDK(
|
563 | 562 | <!-- Start Error Handling [errors] -->
|
564 | 563 | ## Error Handling
|
565 | 564 |
|
566 |
| -Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an exception. |
567 |
| - |
568 |
| -By default, an API error will raise a errors.SDKError exception, which has the following properties: |
| 565 | +[`SDKBaseError`](./src/formance_sdk_python/models/errors/sdkbaseerror.py) is the base class for all HTTP error responses. It has the following properties: |
569 | 566 |
|
570 |
| -| Property | Type | Description | |
571 |
| -|-----------------|------------------|-----------------------| |
572 |
| -| `.status_code` | *int* | The HTTP status code | |
573 |
| -| `.message` | *str* | The error message | |
574 |
| -| `.raw_response` | *httpx.Response* | The raw HTTP response | |
575 |
| -| `.body` | *str* | The response content | |
576 |
| - |
577 |
| -When custom error responses are specified for an operation, the SDK may also raise their associated exceptions. You can refer to respective *Errors* tables in SDK docs for more details on possible exception types for each operation. For example, the `add_metadata_on_transaction_async` method may raise the following exceptions: |
578 |
| - |
579 |
| -| Error Type | Status Code | Content Type | |
580 |
| -| ---------------------- | ----------- | ---------------- | |
581 |
| -| errors.V2ErrorResponse | default | application/json | |
582 |
| -| errors.SDKError | 4XX, 5XX | \*/\* | |
| 567 | +| Property | Type | Description | |
| 568 | +| ------------------ | ---------------- | --------------------------------------------------------------------------------------- | |
| 569 | +| `err.message` | `str` | Error message | |
| 570 | +| `err.status_code` | `int` | HTTP response status code eg `404` | |
| 571 | +| `err.headers` | `httpx.Headers` | HTTP response headers | |
| 572 | +| `err.body` | `str` | HTTP body. Can be empty string if no body is returned. | |
| 573 | +| `err.raw_response` | `httpx.Response` | Raw HTTP response | |
| 574 | +| `err.data` | | Optional. Some errors may contain structured data. [See Error Classes](#error-classes). | |
583 | 575 |
|
584 | 576 | ### Example
|
585 |
| - |
586 | 577 | ```python
|
587 | 578 | from formance_sdk_python import SDK
|
588 | 579 | from formance_sdk_python.models import errors, shared
|
@@ -611,13 +602,51 @@ with SDK(
|
611 | 602 | # Handle response
|
612 | 603 | print(res)
|
613 | 604 |
|
614 |
| - except errors.V2ErrorResponse as e: |
615 |
| - # handle e.data: errors.V2ErrorResponseData |
616 |
| - raise(e) |
617 |
| - except errors.SDKError as e: |
618 |
| - # handle exception |
619 |
| - raise(e) |
| 605 | + |
| 606 | + except errors.SDKBaseError as e: |
| 607 | + # The base class for HTTP error responses |
| 608 | + print(e.message) |
| 609 | + print(e.status_code) |
| 610 | + print(e.body) |
| 611 | + print(e.headers) |
| 612 | + print(e.raw_response) |
| 613 | + |
| 614 | + # Depending on the method different errors may be thrown |
| 615 | + if isinstance(e, errors.V2ErrorResponse): |
| 616 | + print(e.data.details) # Optional[str] |
| 617 | + print(e.data.error_code) # shared.V2ErrorsEnum |
| 618 | + print(e.data.error_message) # str |
620 | 619 | ```
|
| 620 | + |
| 621 | +### Error Classes |
| 622 | +**Primary error:** |
| 623 | +* [`SDKBaseError`](./src/formance_sdk_python/models/errors/sdkbaseerror.py): The base class for HTTP error responses. |
| 624 | + |
| 625 | +<details><summary>Less common errors (14)</summary> |
| 626 | + |
| 627 | +<br /> |
| 628 | + |
| 629 | +**Network errors:** |
| 630 | +* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors. |
| 631 | + * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server. |
| 632 | + * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out. |
| 633 | + |
| 634 | + |
| 635 | +**Inherit from [`SDKBaseError`](./src/formance_sdk_python/models/errors/sdkbaseerror.py)**: |
| 636 | +* [`V3ErrorResponse`](./src/formance_sdk_python/models/errors/v3errorresponse.py): Error. Applicable to 46 of 219 methods.* |
| 637 | +* [`PaymentsErrorResponse`](./src/formance_sdk_python/models/errors/paymentserrorresponse.py): Error. Applicable to 45 of 219 methods.* |
| 638 | +* [`V2ErrorResponse`](./src/formance_sdk_python/models/errors/v2errorresponse.py): Error. Applicable to 26 of 219 methods.* |
| 639 | +* [`ErrorResponse`](./src/formance_sdk_python/models/errors/errorresponse.py): Applicable to 19 of 219 methods.* |
| 640 | +* [`V2Error`](./src/formance_sdk_python/models/errors/v2error.py): General error. Applicable to 18 of 219 methods.* |
| 641 | +* [`Error`](./src/formance_sdk_python/models/errors/error.py): General error. Applicable to 17 of 219 methods.* |
| 642 | +* [`WalletsErrorResponse`](./src/formance_sdk_python/models/errors/walletserrorresponse.py): Applicable to 15 of 219 methods.* |
| 643 | +* [`ReconciliationErrorResponse`](./src/formance_sdk_python/models/errors/reconciliationerrorresponse.py): Error response. Applicable to 8 of 219 methods.* |
| 644 | +* [`WebhooksErrorResponse`](./src/formance_sdk_python/models/errors/webhookserrorresponse.py): Error. Applicable to 8 of 219 methods.* |
| 645 | +* [`ResponseValidationError`](./src/formance_sdk_python/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute. |
| 646 | + |
| 647 | +</details> |
| 648 | + |
| 649 | +\* Check [the method documentation](#available-resources-and-operations) to see if the error is applicable. |
621 | 650 | <!-- End Error Handling [errors] -->
|
622 | 651 |
|
623 | 652 | <!-- Start Server Selection [server] -->
|
|
0 commit comments