Skip to content

Commit 5604e0d

Browse files
Merge pull request #274 from QualiSystems/shellfoundry_response_message
fix response
2 parents d597678 + 73e7f7a commit 5604e0d

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

shellfoundry/utilities/shell_package_installer.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,23 @@ def _add_new_shell(self, client, package_full_path):
216216
)
217217

218218
def _parse_installation_error(self, base_message, error):
219+
error_str = str(error)
220+
cs_message = error_str # Default to full error string
221+
219222
try:
220-
cs_message = json.loads(str(error))["Message"]
221-
except Exception:
222-
cs_message = ""
223+
# Check if it's a PackagingRestApiError with embedded JSON response
224+
if "response:" in error_str:
225+
# Extract JSON part after "response: "
226+
json_start = error_str.find("response:") + len("response:")
227+
json_str = error_str[json_start:].strip().rstrip("')")
228+
cs_message = json.loads(json_str)["Message"]
229+
else:
230+
# Try to parse the error string directly as JSON
231+
cs_message = json.loads(error_str)["Message"]
232+
except (json.JSONDecodeError, KeyError, ValueError):
233+
# If JSON parsing fails, keep the full error string
234+
pass
235+
223236
return "{}. CloudShell responded with: '{}'".format(base_message, cs_message)
224237

225238
def _increase_pbar(self, pbar, time_wait):

0 commit comments

Comments
 (0)