Skip to content

Commit 5739327

Browse files
wip
1 parent 25e6b0d commit 5739327

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/uipath/_cli/_auth/_portal_service.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import click
66
import httpx
77

8+
from ..._utils._errors import handle_errors
89
from .._utils._console import ConsoleLogger
910
from ._models import TenantsAndOrganizationInfoResponse, TokenData
1011
from ._oidc_utils import get_auth_config
@@ -49,21 +50,15 @@ def update_token_data(self, token_data: TokenData):
4950

5051
def get_tenants_and_organizations(self) -> TenantsAndOrganizationInfoResponse:
5152
url = f"https://{self.domain}.uipath.com/{self.prt_id}/portal_/api/filtering/leftnav/tenantsAndOrganizationInfo"
52-
response = client.get(
53-
url, headers={"Authorization": f"Bearer {self.access_token}"}
54-
)
55-
if response.status_code < 400:
53+
headers = {"Authorization": f"Bearer {self.access_token}"}
54+
55+
with handle_errors():
56+
response = client.get(url, headers=headers)
57+
5658
result = response.json()
5759
self._tenants_and_organizations = result
60+
5861
return result
59-
elif response.status_code == 401:
60-
console.error("Unauthorized")
61-
else:
62-
console.error(
63-
f"Failed to get tenants and organizations: {response.status_code} {response.text}"
64-
)
65-
# Can't reach here, console.error exits, linting
66-
raise Exception("Failed to get tenants")
6762

6863
def get_uipath_orchestrator_url(self) -> str:
6964
if self._tenants_and_organizations is None:

src/uipath/_cli/cli_publish.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import httpx
77
from dotenv import load_dotenv
88

9+
from .._utils._errors import handle_errors
910
from ._utils._common import get_env_vars
1011
from ._utils._console import ConsoleLogger
1112
from ._utils._folders import get_personal_workspace_info
@@ -121,7 +122,7 @@ def publish(feed):
121122
else:
122123
url = url + "?feedId=" + feed
123124

124-
with open(package_to_publish_path, "rb") as f:
125+
with open(package_to_publish_path, "rb") as f, handle_errors():
125126
files = {"file": (package_to_publish_path, f, "application/octet-stream")}
126127
response = client.post(url, headers=headers, files=files)
127128

0 commit comments

Comments
 (0)