Skip to content

Commit 260412f

Browse files
committed
modify decorator so it is only raised on 401 error
1 parent 7d5ad36 commit 260412f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/unstructured_client/utils/_decorators.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ def suggest_defining_url_if_401(func: Callable[_P, operations.PartitionResponse]
5858
def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> operations.PartitionResponse:
5959
try:
6060
return func(*args, **kwargs)
61-
except errors.SDKError:
62-
general_obj: General = args[0] # type: ignore
63-
if not general_obj.sdk_configuration.server_url:
64-
warnings.warn("If intending to use the paid API, please define `server_url` in your request.")
61+
except errors.SDKError as e:
62+
if e.status_code == 401:
63+
general_obj: General = args[0] # type: ignore
64+
if not general_obj.sdk_configuration.server_url:
65+
warnings.warn("If intending to use the paid API, please define `server_url` in your request.")
66+
6567
return func(*args, **kwargs)
6668

6769
return wrapper

0 commit comments

Comments
 (0)