Skip to content

Commit 6b594a8

Browse files
committed
[Enhancement] Show error message for non-existent destination path
1 parent bb74552 commit 6b594a8

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

SymlinkCreator/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,5 @@
5252
// by using the '*' as shown below:
5353
// [assembly: AssemblyVersion("1.0.*")]
5454

55-
[assembly: AssemblyVersion("1.2.1")]
56-
[assembly: AssemblyFileVersion("1.2.1")]
55+
[assembly: AssemblyVersion("1.2.2")]
56+
[assembly: AssemblyFileVersion("1.2.2")]

SymlinkCreator/core/SymlinkAgent.cs

+1-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public void CreateSymlinks()
4242
// check for destination path
4343
if (!Directory.Exists(_destinationPath))
4444
{
45-
Debug.WriteLine("Destination path does not exist: " + _destinationPath);
46-
return;
45+
throw new FileNotFoundException("Destination path does not exist", _destinationPath);
4746
}
4847

4948
// remove the last '\' character from the path if exists

SymlinkCreator/ui/mainWindow/MainWindow.xaml.cs

+9-3
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,15 @@ private void CreateSymlinksButton_OnClick(object sender, RoutedEventArgs e)
158158
mainWindowViewModel.ShouldUseRelativePath,
159159
mainWindowViewModel.ShouldRetainScriptFile);
160160

161-
symlinkAgent.CreateSymlinks();
162-
163-
MessageBox.Show("Execution completed.", "Done!", MessageBoxButton.OK, MessageBoxImage.Information);
161+
try
162+
{
163+
symlinkAgent.CreateSymlinks();
164+
MessageBox.Show("Execution completed.", "Done!", MessageBoxButton.OK, MessageBoxImage.Information);
165+
}
166+
catch (FileNotFoundException ex)
167+
{
168+
MessageBox.Show(ex.Message + ":\n" + ex.FileName, "Error!", MessageBoxButton.OK, MessageBoxImage.Error);
169+
}
164170
}
165171

166172
private void AboutButton_OnClick(object sender, RoutedEventArgs e)

0 commit comments

Comments
 (0)