mirror of
https://github.com/cyanfish/naps2.git
synced 2024-10-04 19:37:15 +03:00
Fix some exceptions being swallowed by SaveImagesOperation
This commit is contained in:
parent
ab4802f69d
commit
96e9c8cbd3
@ -36,7 +36,6 @@ namespace NAPS2.ImportExport.Images
|
||||
{
|
||||
public class SaveImagesOperation : OperationBase
|
||||
{
|
||||
private readonly IErrorOutput errorOutput;
|
||||
private readonly FileNamePlaceholders fileNamePlaceholders;
|
||||
private readonly ImageSettingsContainer imageSettingsContainer;
|
||||
private readonly IOverwritePrompt overwritePrompt;
|
||||
@ -45,9 +44,8 @@ namespace NAPS2.ImportExport.Images
|
||||
private bool cancel;
|
||||
private Thread thread;
|
||||
|
||||
public SaveImagesOperation(IErrorOutput errorOutput, FileNamePlaceholders fileNamePlaceholders, ImageSettingsContainer imageSettingsContainer, IOverwritePrompt overwritePrompt, ThreadFactory threadFactory)
|
||||
public SaveImagesOperation(FileNamePlaceholders fileNamePlaceholders, ImageSettingsContainer imageSettingsContainer, IOverwritePrompt overwritePrompt, ThreadFactory threadFactory)
|
||||
{
|
||||
this.errorOutput = errorOutput;
|
||||
this.fileNamePlaceholders = fileNamePlaceholders;
|
||||
this.imageSettingsContainer = imageSettingsContainer;
|
||||
this.overwritePrompt = overwritePrompt;
|
||||
@ -194,9 +192,13 @@ namespace NAPS2.ImportExport.Images
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
public void WaitUntilFinished()
|
||||
public void WaitUntilFinished(bool throwOnError = true)
|
||||
{
|
||||
thread.Join();
|
||||
if (throwOnError && LastError != null)
|
||||
{
|
||||
throw new Exception(LastError.ErrorMessage, LastError.Exception);
|
||||
}
|
||||
}
|
||||
|
||||
private static ImageFormat GetImageFormat(string fileName)
|
||||
|
@ -20,6 +20,8 @@ namespace NAPS2.Operation
|
||||
|
||||
public event EventHandler<OperationErrorEventArgs> Error;
|
||||
|
||||
protected OperationErrorEventArgs LastError { get; private set; }
|
||||
|
||||
protected void InvokeFinished()
|
||||
{
|
||||
if (Finished != null)
|
||||
@ -38,9 +40,11 @@ namespace NAPS2.Operation
|
||||
|
||||
protected void InvokeError(string message, Exception exception)
|
||||
{
|
||||
var args = new OperationErrorEventArgs(message, exception);
|
||||
LastError = args;
|
||||
if (Error != null)
|
||||
{
|
||||
Error.Invoke(this, new OperationErrorEventArgs(message, exception));
|
||||
Error.Invoke(this, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user