Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## 0.41.0

### Enhancements

### Features
* Provide a base `UnstructuredClientError` to capture every error raised by the SDK. Note that some exceptions such as `SDKError` now have more information in the `message` field. This will impact any users who rely on string matching in their error handling.

### Fixes

## 0.37.3

### Enhancements
Expand Down
4 changes: 2 additions & 2 deletions _test_contract/platform_api/test_destinations.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_list_destinations_5xx_code(
)
requests = httpx_mock.get_requests()
assert len(requests) >= 1
assert excinfo.value.message == "API error occurred"
assert "API error occurred" in excinfo.value.message
assert excinfo.value.status_code == error_status_code


Expand Down Expand Up @@ -177,7 +177,7 @@ def test_get_destination_not_found(

requests = httpx_mock.get_requests()
assert len(requests) == 1
assert excinfo.value.message == "API error occurred"
assert "API error occurred" in excinfo.value.message
assert excinfo.value.status_code == 404


Expand Down
4 changes: 2 additions & 2 deletions _test_contract/platform_api/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_get_job_not_found(
)

assert e.value.status_code == 404
assert e.value.message == "API error occurred"
assert "API error occurred" in e.value.message

requests = httpx_mock.get_requests()
assert len(requests) == 1
Expand Down Expand Up @@ -130,7 +130,7 @@ def test_get_job_error(httpx_mock, platform_client: UnstructuredClient, platform
)

assert e.value.status_code == 500
assert e.value.message == "API error occurred"
assert "API error occurred" in e.value.message

requests = httpx_mock.get_requests()
assert len(requests) == 4
Expand Down
4 changes: 2 additions & 2 deletions _test_contract/platform_api/test_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def test_list_sources_5xx_code(
platform_client.sources.list_sources(request=operations.ListSourcesRequest())
requests = httpx_mock.get_requests()
assert len(requests) >= 1
assert excinfo.value.message == "API error occurred"
assert "API error occurred" in excinfo.value.message
assert excinfo.value.status_code == error_status_code


Expand Down Expand Up @@ -176,7 +176,7 @@ def test_get_source_not_found(

requests = httpx_mock.get_requests()
assert len(requests) == 1
assert excinfo.value.message == "API error occurred"
assert "API error occurred" in excinfo.value.message
assert excinfo.value.status_code == 404


Expand Down
8 changes: 4 additions & 4 deletions _test_contract/platform_api/test_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from unstructured_client import UnstructuredClient
from unstructured_client.models import shared, operations
from unstructured_client.models.errors import SDKError
from unstructured_client.models.errors import UnstructuredClientError


def test_list_workflows(httpx_mock, platform_client: UnstructuredClient, platform_api_url: str):
Expand Down Expand Up @@ -108,10 +108,10 @@ def test_list_workflows_error(
status_code=error_status_code,
)

with pytest.raises(SDKError) as excinfo:
with pytest.raises(UnstructuredClientError) as error:
platform_client.workflows.list_workflows(request=operations.ListWorkflowsRequest())
assert excinfo.value.status_code == error_status_code
assert excinfo.value.message == "API error occurred"
assert error.value.status_code == error_status_code
assert "API error occurred" in error.value.message


def test_create_workflow(httpx_mock, platform_client: UnstructuredClient, platform_api_url: str):
Expand Down
2 changes: 1 addition & 1 deletion gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ generation:
oAuth2ClientCredentialsEnabled: false
oAuth2PasswordEnabled: false
python:
version: 0.40.0
version: 0.41.0
additionalDependencies:
dev:
deepdiff: '>=6.0'
Expand Down
8 changes: 4 additions & 4 deletions src/unstructured_client/basesdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def do():

if http_res is None:
logger.debug("Raising no response SDK error")
raise errors.SDKError("No response received")
raise errors.NoResponseError("No response received")

logger.debug(
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
Expand All @@ -270,7 +270,7 @@ def do():
http_res = result
else:
logger.debug("Raising unexpected SDK error")
raise errors.SDKError("Unexpected error occurred")
raise errors.SDKError("Unexpected error occurred", http_res)

return http_res

Expand Down Expand Up @@ -321,7 +321,7 @@ async def do():

if http_res is None:
logger.debug("Raising no response SDK error")
raise errors.SDKError("No response received")
raise errors.NoResponseError("No response received")

logger.debug(
"Response:\nStatus Code: %s\nURL: %s\nHeaders: %s\nBody: %s",
Expand All @@ -342,7 +342,7 @@ async def do():
http_res = result
else:
logger.debug("Raising unexpected SDK error")
raise errors.SDKError("Unexpected error occurred")
raise errors.SDKError("Unexpected error occurred", http_res)

return http_res

Expand Down
Loading