Skip to content

Commit 6f56991

Browse files
committed
Throw in the necessary error checks for facade calls
1 parent 0424650 commit 6f56991

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

juju/application.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,16 @@ async def refresh(
654654
# First we need to make sure we have the resources for the charm that's
655655
# coming
656656

657-
# Get the listof resources needed to deploy this charm
657+
# Get the list of resources needed to deploy this charm
658658
if Schema.CHARM_HUB.matches(parsed_url.schema):
659659
# Charmhub charms
660660
charmhub = self.model.charmhub
661661
charm_resources = await charmhub.list_resources(charm_name)
662662

663663
res = await app_facade.GetCharmURLOrigin(application=charm_name)
664+
665+
if res.error is not None:
666+
raise JujuError(f'{res.code} : {res.message}')
664667
charm_url = res.url
665668
origin = res.charm_origin
666669

@@ -670,14 +673,17 @@ async def refresh(
670673
origin.track = ch.track
671674

672675
charms_facade = client.CharmsFacade.from_connection(self.connection)
673-
resolved_charm = await charms_facade.ResolveCharms(resolve=[client.ResolveCharmWithChannel(
676+
resolved_charm_with_channel_results = await charms_facade.ResolveCharms(resolve=[client.ResolveCharmWithChannel(
674677
charm_origin=origin,
675678
switch_charm=False,
676679
reference=charm_url,
677680
)])
678-
# TODO: error check here
679-
dest_origin = resolved_charm.results[0].charm_origin
680-
charm_url = resolved_charm.results[0].url
681+
resolved_charm = resolved_charm_with_channel_results.results[0]
682+
683+
if resolved_charm.error is not None:
684+
raise JujuError(f'{res.code} : {res.message}')
685+
dest_origin = resolved_charm.charm_origin
686+
charm_url = resolved_charm.url
681687

682688
await charms_facade.AddCharm(url=charm_url,
683689
force=force,

0 commit comments

Comments
 (0)