save:
try
{
s.Save();
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
FSErrorDialog fsError = new(ex, FSVerb.Access, new FileInfo(path), Button.Retry, Button.Ignore);
if (fsError.ShowDialog().ClickedButton == Button.Retry)
{
goto save;
}
}
The Save()
method saves the object to the disk.
If an exogenous exception occurs, the user is prompted to retry the operation to avoid loosing unsaved data.
I know I could use a while (true)
loop with break statements but I think the goto approach is more readable. It also saves an indentation level.
I am scared of using goto.
Is this a legitimate use of goto statements?