exception handling

This commit is contained in:
cdwcgt 2023-04-09 15:09:18 +09:00
parent ce6a87b4a3
commit 5d64c1b7bf
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
1 changed files with 9 additions and 3 deletions

View File

@ -124,8 +124,15 @@ public async Task<bool> ExportAsync(Live<TModel> model, CancellationToken cancel
cancellationToken == CancellationToken.None ? notification.CancellationToken : cancellationToken).ConfigureAwait(false);
}
}
catch (OperationCanceledException)
catch
{
notification.State = ProgressNotificationState.Cancelled;
throw;
}
finally
{
// Determines whether to export repeatedly, so he must be removed from the list at the end whether there is a error.
exporting_models.Remove(model);
}
// cleanup if export is failed or canceled.
@ -141,7 +148,6 @@ public async Task<bool> ExportAsync(Live<TModel> model, CancellationToken cancel
notification.State = ProgressNotificationState.Completed;
}
exporting_models.Remove(model);
return success;
}
@ -171,7 +177,7 @@ public Task<bool> ExportToStreamAsync(Live<TModel> model, Stream stream, Progres
if (t.IsFaulted)
{
Logger.Error(t.Exception, "An error occurred while exporting", LoggingTarget.Database);
return false;
throw t.Exception!;
}
return true;