@@ -658,13 +658,16 @@ async def refresh(
658658 # First we need to make sure we have the resources for the charm that's
659659 # coming
660660
661- # Get the listof resources needed to deploy this charm
661+ # Get the list of resources needed to deploy this charm
662662 if Schema .CHARM_HUB .matches (parsed_url .schema ):
663663 # Charmhub charms
664664 charmhub = self .model .charmhub
665665 charm_resources = await charmhub .list_resources (charm_name )
666666
667667 res = await app_facade .GetCharmURLOrigin (application = charm_name )
668+
669+ if res .error is not None :
670+ raise JujuError (f'{ res .code } : { res .message } ' )
668671 charm_url = res .url
669672 origin = res .charm_origin
670673
@@ -674,14 +677,17 @@ async def refresh(
674677 origin .track = ch .track
675678
676679 charms_facade = client .CharmsFacade .from_connection (self .connection )
677- resolved_charm = await charms_facade .ResolveCharms (resolve = [client .ResolveCharmWithChannel (
680+ resolved_charm_with_channel_results = await charms_facade .ResolveCharms (resolve = [client .ResolveCharmWithChannel (
678681 charm_origin = origin ,
679682 switch_charm = False ,
680683 reference = charm_url ,
681684 )])
682- # TODO: error check here
683- dest_origin = resolved_charm .results [0 ].charm_origin
684- charm_url = resolved_charm .results [0 ].url
685+ resolved_charm = resolved_charm_with_channel_results .results [0 ]
686+
687+ if resolved_charm .error is not None :
688+ raise JujuError (f'{ res .code } : { res .message } ' )
689+ dest_origin = resolved_charm .charm_origin
690+ charm_url = resolved_charm .url
685691
686692 await charms_facade .AddCharm (url = charm_url ,
687693 force = force ,
0 commit comments