Skip to content

Commit ee5a074

Browse files
authored
Use SDKError in example snippet
1 parent f0b81ca commit ee5a074

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Diff for: README.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Only the `files` parameter is required. See the [general partition](docs/sdks/ge
3030
```python
3131
from unstructured_client import UnstructuredClient
3232
from unstructured_client.models import shared
33+
from unstructured_client.models.errors import SDKError
3334

3435
# Note - in an upcoming release, the Security object is removed
3536
# You'll pass the api key directly
@@ -40,17 +41,22 @@ s = UnstructuredClient(
4041
)
4142

4243
filename = "sample-docs/layout-parser-paper.pdf"
44+
file = open(filename, "rb")
4345

44-
with open(filename, "rb") as f:
45-
req = shared.PartitionParameters(
46-
files=shared.PartitionParametersFiles(
47-
content=f.read(),
48-
files=filename,
49-
)
50-
)
51-
46+
req = shared.PartitionParameters(
47+
files=shared.PartitionParametersFiles(
48+
content=file.read(),
49+
files=filename,
50+
),
51+
# Other partition params
52+
strategy="fast",
53+
)
54+
55+
try:
5256
res = s.general.partition(req)
5357
print(res.elements[0])
58+
except SDKError as e:
59+
print(e)
5460

5561
# {
5662
# 'type': 'Title',

0 commit comments

Comments
 (0)