Skip to content

Commit 6e6a6dc

Browse files
Improve error handling for Schematics region failures
- Track failed regions instead of silently ignoring all errors - Raise RuntimeError if ALL regions fail (prevents silent failures) - Include detailed error messages for debugging - Addresses CodeRabbit review feedback Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 8868c53 commit 6e6a6dc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,32 @@ def get_all_workspaces(self):
4545
"""
4646
This method lists all available schematics workspaces
4747
:return:
48+
:raises: RuntimeError if unable to query any region
4849
"""
4950
# list_locations() was removed from IBM Schematics SDK
5051
# Use known IBM Cloud regions instead
5152
known_regions = ['us-south', 'us-east', 'eu-de', 'eu-gb']
5253
resources_list = {}
54+
failed_regions = []
5355

5456
for region in known_regions:
5557
try:
5658
self.set_service_url(region)
5759
workspaces = self.get_workspaces()
5860
if workspaces:
5961
resources_list[region] = workspaces
60-
except Exception:
61-
# Skip regions where schematics is not available or no access
62+
except Exception as exc:
63+
# Track failed regions for debugging
64+
failed_regions.append((region, str(exc)))
6265
continue
6366

67+
# If all regions failed, raise error instead of returning empty dict
68+
if not resources_list and len(failed_regions) == len(known_regions):
69+
failed_details = '; '.join(f"{region}: {error}" for region, error in failed_regions)
70+
raise RuntimeError(
71+
f"Unable to list Schematics workspaces in any region. "
72+
f"All {len(known_regions)} regions failed. "
73+
f"Check credentials and permissions. Details: {failed_details}"
74+
)
75+
6476
return resources_list

0 commit comments

Comments
 (0)