Skip to content

Commit 153c78a

Browse files
committed
Handle Errors during add process
1 parent d4d8552 commit 153c78a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

src/EasySign.CommandLine/BundleWorker.cs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,31 @@ protected virtual void RunAdd(StatusContext statusContext, bool replace)
4444
_ = Parallel.ForEach(Utilities.SafeEnumerateFiles(Bundle.RootPath, "*"), file =>
4545
{
4646
if (file == Bundle.BundlePath) return;
47-
4847
var entryName = Manifest.GetNormalizedEntryName(Path.GetRelativePath(Bundle.RootPath, file));
4948

50-
if (Bundle.Manifest.Entries.ContainsKey(entryName))
49+
try
5150
{
52-
if (!replace)
51+
if (Bundle.Manifest.Entries.ContainsKey(entryName))
5352
{
54-
AnsiConsole.MarkupLine($"[{Color.Orange1}]Exists:[/] {entryName}");
55-
return;
53+
if (!replace)
54+
{
55+
AnsiConsole.MarkupLine($"[{Color.Orange1}]Exists:[/] {entryName}");
56+
return;
57+
}
58+
59+
Bundle.DeleteEntry(entryName);
60+
Bundle.AddEntry(file);
61+
AnsiConsole.MarkupLine($"[{Color.Cyan2}]Replaced:[/] {entryName}");
62+
}
63+
else
64+
{
65+
Bundle.AddEntry(file);
66+
AnsiConsole.MarkupLine($"[blue]Added:[/] {entryName}");
5667
}
57-
58-
Bundle.DeleteEntry(entryName);
59-
Bundle.AddEntry(file);
60-
AnsiConsole.MarkupLine($"[{Color.Cyan2}]Replaced:[/] {entryName}");
6168
}
62-
else
69+
catch (Exception ex)
6370
{
64-
Bundle.AddEntry(file);
65-
AnsiConsole.MarkupLine($"[blue]Added:[/] {entryName}");
71+
AnsiConsole.MarkupLine($"[{Color.Red}]Error:[/] {entryName} ({ex.GetType().Name}: {ex.Message})");
6672
}
6773
});
6874

0 commit comments

Comments
 (0)