Skip to content

Commit

Permalink
RDX v1.0.5; upload error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Decimation committed May 22, 2024
1 parent 49dd938 commit d34fd61
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 14 deletions.
20 changes: 13 additions & 7 deletions SmartImage.Rdx/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,29 @@ public static async Task<int> Main(string[] args)
c.PropagateExceptions();
var helpProvider = new CustomHelpProvider(c.Settings);
c.SetHelpProvider(helpProvider);

c.AddCommand<IntegrationCommand>("integrate")
.WithDescription("Configure system integration such as context menu");
});

try {
var x = await app.RunAsync(args);
int x = SearchCommand.EC_OK;

if (x != SearchCommand.EC_OK) {
AConsole.Confirm("Press any key to continue");
}
try {
x = await app.RunAsync(args);

return x;
}
catch (Exception e) {
AConsole.WriteException(e);
return SearchCommand.EC_ERROR;
x = SearchCommand.EC_ERROR;
}
finally {

if (x != SearchCommand.EC_OK) {
AConsole.Confirm("Press any key to continue");
}
}

return x;
}

}
28 changes: 21 additions & 7 deletions SmartImage.Rdx/SearchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ internal sealed class SearchCommand : AsyncCommand<SearchCommandSettings>, IDisp
public const int EC_OK = 0;

public static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
public static readonly Version Version = Assembly.GetName().Version;
public static readonly Version Version = Assembly.GetName().Version;

public SearchCommand()
{
Expand All @@ -92,16 +92,19 @@ public SearchCommand()

#region

private async Task SetupSearchAsync(ProgressContext ctx)
private async Task<bool> SetupSearchAsync(ProgressContext ctx)
{
var p = ctx.AddTask("Creating query");
p.IsIndeterminate = true;
bool ok = true;

Query = await SearchQuery.TryCreateAsync(m_scs.Query);

if (Query == SearchQuery.Null) {
throw new SmartImageException($"Could not create query"); //todo
// throw new SmartImageException($"Could not create query"); //todo

ok = false;
goto ret;
}

p.Increment(COMPLETE / 2);
Expand All @@ -112,10 +115,15 @@ private async Task SetupSearchAsync(ProgressContext ctx)
var url = await Query.UploadAsync();

if (url == null) {
throw new SmartImageException("Could not upload query"); //todo
// throw new SmartImageException("Could not upload query"); //todo
ok = false;
goto ret;
}

p.Increment(COMPLETE / 2);

ret:
return ok;
}

private async Task InitConfigAsync([CBN] object c)
Expand Down Expand Up @@ -294,11 +302,17 @@ public override async Task<int> ExecuteAsync(CommandContext context, SearchComma

var task = AConsole.Progress()
.AutoRefresh(true)
.StartAsync(SetupSearchAsync)
.ContinueWith(InitConfigAsync);
.StartAsync(SetupSearchAsync);

try {
await task;
var ok = await task;

if (ok) {
await InitConfigAsync(ok);
}
else {
throw new SmartImageException("Could not upload query");
}
}
catch (Exception e) {
AConsole.WriteException(e);
Expand Down

0 comments on commit d34fd61

Please sign in to comment.