Skip to content

Commit

Permalink
fix(apply): prints resource name when apply or delete fails
Browse files Browse the repository at this point in the history
When the apply or delete command fails, it doesn't clearly mention which
resource failed. This commit fixes the issue by printing the resource
name along with the eror.

Wrike Ticket: https://www.wrike.com/open.htm?id=1480954550
  • Loading branch information
pallabpain committed Sep 4, 2024
1 parent 843b793 commit 1952929
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions riocli/apply/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,12 @@ def _apply_manifest(self, obj_key: str, *args, **kwargs) -> None:

obj = self.objects[obj_key]
kls = get_model(obj)
kls.validate(obj)

try:
kls.validate(obj)
except Exception as ex:
raise Exception(f'invalid manifest {obj_key}: {str(ex)}')

ist = kls(munchify(obj))

obj_key = click.style(obj_key, bold=True)
Expand All @@ -274,7 +279,7 @@ def _apply_manifest(self, obj_key: str, *args, **kwargs) -> None:
except Exception as ex:
message_with_prompt("{} Failed to apply {}. Error: {}".format(
Symbols.ERROR, obj_key, str(ex)), fg=Colors.RED, spinner=spinner)
raise ex
raise Exception(f'{obj_key}: {str(ex)}')

def _delete_manifest(self, obj_key: str, *args, **kwargs) -> None:
"""Instantiate and delete the object manifest"""
Expand All @@ -283,7 +288,12 @@ def _delete_manifest(self, obj_key: str, *args, **kwargs) -> None:

obj = self.objects[obj_key]
kls = get_model(obj)
kls.validate(obj)

try:
kls.validate(obj)
except Exception as ex:
raise Exception(f'invalid manifest {obj_key}: {str(ex)}')

ist = kls(munchify(obj))

obj_key = click.style(obj_key, bold=True)
Expand All @@ -309,7 +319,7 @@ def _delete_manifest(self, obj_key: str, *args, **kwargs) -> None:
except Exception as ex:
message_with_prompt("{} Failed to delete {}. Error: {}".format(
Symbols.ERROR, obj_key, str(ex)), fg=Colors.RED, spinner=spinner)
raise ex
raise Exception(f'{obj_key}: {str(ex)}')

def _process_file_list(self, files):
for f in files:
Expand Down

0 comments on commit 1952929

Please sign in to comment.