@@ -65,7 +65,7 @@ internal sealed class SearchCommand : AsyncCommand<SearchCommandSettings>, IDisp
6565 public const int EC_OK = 0 ;
6666
6767 public static readonly Assembly Assembly = Assembly . GetExecutingAssembly ( ) ;
68- public static readonly Version Version = Assembly . GetName ( ) . Version ;
68+ public static readonly Version Version = Assembly . GetName ( ) . Version ;
6969
7070 public SearchCommand ( )
7171 {
@@ -92,16 +92,19 @@ public SearchCommand()
9292
9393 #region
9494
95- private async Task SetupSearchAsync ( ProgressContext ctx )
95+ private async Task < bool > SetupSearchAsync ( ProgressContext ctx )
9696 {
9797 var p = ctx . AddTask ( "Creating query" ) ;
9898 p . IsIndeterminate = true ;
99+ bool ok = true ;
99100
100101 Query = await SearchQuery . TryCreateAsync ( m_scs . Query ) ;
101102
102103 if ( Query == SearchQuery . Null ) {
103- throw new SmartImageException ( $ "Could not create query") ; //todo
104+ // throw new SmartImageException($"Could not create query"); //todo
104105
106+ ok = false ;
107+ goto ret ;
105108 }
106109
107110 p . Increment ( COMPLETE / 2 ) ;
@@ -112,10 +115,15 @@ private async Task SetupSearchAsync(ProgressContext ctx)
112115 var url = await Query . UploadAsync ( ) ;
113116
114117 if ( url == null ) {
115- throw new SmartImageException ( "Could not upload query" ) ; //todo
118+ // throw new SmartImageException("Could not upload query"); //todo
119+ ok = false ;
120+ goto ret ;
116121 }
117122
118123 p . Increment ( COMPLETE / 2 ) ;
124+
125+ ret :
126+ return ok ;
119127 }
120128
121129 private async Task InitConfigAsync ( [ CBN ] object c )
@@ -294,11 +302,17 @@ public override async Task<int> ExecuteAsync(CommandContext context, SearchComma
294302
295303 var task = AConsole . Progress ( )
296304 . AutoRefresh ( true )
297- . StartAsync ( SetupSearchAsync )
298- . ContinueWith ( InitConfigAsync ) ;
305+ . StartAsync ( SetupSearchAsync ) ;
299306
300307 try {
301- await task ;
308+ var ok = await task ;
309+
310+ if ( ok ) {
311+ await InitConfigAsync ( ok ) ;
312+ }
313+ else {
314+ throw new SmartImageException ( "Could not upload query" ) ;
315+ }
302316 }
303317 catch ( Exception e ) {
304318 AConsole . WriteException ( e ) ;
0 commit comments