-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VCI-724: Fail installation of modules on errors (#110)
- Loading branch information
1 parent
6d0b59f
commit ca51b1a
Showing
7 changed files
with
54 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 17 additions & 3 deletions
20
src/VirtoCommerce.Build/PlatformTools/ModulesInstallerBase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,37 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using VirtoCommerce.Platform.Core.Modularity; | ||
|
||
namespace VirtoCommerce.Build.PlatformTools | ||
{ | ||
public abstract class ModulesInstallerBase | ||
{ | ||
public virtual Task Install(ModuleSource source) | ||
public virtual Task Install(ModuleSource source, IProgress<ProgressMessage> progress) | ||
{ | ||
try | ||
{ | ||
return InnerInstall(source); | ||
return InnerInstall(source, progress); | ||
} | ||
catch (Exception exception) | ||
{ | ||
progress.ReportError(exception.Message); | ||
throw new ModuleInstallationException("Error while module installation", exception); | ||
} | ||
} | ||
|
||
protected abstract Task InnerInstall(ModuleSource source); | ||
protected abstract Task InnerInstall(ModuleSource source, IProgress<ProgressMessage> progress); | ||
} | ||
|
||
public static class ProgressExtension | ||
{ | ||
public static void ReportInfo(this IProgress<ProgressMessage> progress, string message) | ||
{ | ||
progress.Report(new ProgressMessage { Level = ProgressMessageLevel.Info, Message = message }); | ||
} | ||
public static void ReportError(this IProgress<ProgressMessage> progress, string message) | ||
{ | ||
progress.Report(new ProgressMessage { Level = ProgressMessageLevel.Error, Message = message }); | ||
} | ||
} | ||
} | ||
|