Throwing an exception when specifying a non-existing recipe.

This commit is contained in:
Sipke Schoorstra
2015-08-04 17:08:15 +01:00
parent 783281321c
commit 8cda6b54c6
2 changed files with 8 additions and 4 deletions

View File

@@ -27,8 +27,7 @@ namespace Orchard.Recipes.Services {
public string Execute(Recipe recipe) { public string Execute(Recipe recipe) {
if (recipe == null) { if (recipe == null) {
Logger.Information("Cannot execute a null recipe. No work has been scheduled."); throw new ArgumentNullException("recipe");
return null;
} }
if (!recipe.RecipeSteps.Any()) { if (!recipe.RecipeSteps.Any()) {

View File

@@ -27,7 +27,7 @@ using Orchard.Utility.Extensions;
namespace Orchard.Setup.Services namespace Orchard.Setup.Services
{ {
public class SetupService : ISetupService { public class SetupService : ISetupService {
private readonly ShellSettings _shellSettings; private readonly ShellSettings _shellSettings;
private readonly IOrchardHost _orchardHost; private readonly IOrchardHost _orchardHost;
private readonly IShellSettingsManager _shellSettingsManager; private readonly IShellSettingsManager _shellSettingsManager;
@@ -217,7 +217,12 @@ namespace Orchard.Setup.Services
cultureManager.AddCulture("en-US"); cultureManager.AddCulture("en-US");
var recipeManager = environment.Resolve<IRecipeManager>(); var recipeManager = environment.Resolve<IRecipeManager>();
string executionId = recipeManager.Execute(Recipes().FirstOrDefault(r => r.Name.Equals(context.Recipe, StringComparison.OrdinalIgnoreCase))); var recipe = Recipes().FirstOrDefault(r => r.Name.Equals(context.Recipe, StringComparison.OrdinalIgnoreCase));
if(recipe == null)
throw new OrchardException(T("The recipe '{0}' could not be found.", context.Recipe));
var executionId = recipeManager.Execute(recipe);
// null check: temporary fix for running setup in command line // null check: temporary fix for running setup in command line
if (HttpContext.Current != null) { if (HttpContext.Current != null) {