mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Improved exception message.
When developers accidentally add recipes to a module with the same name, a "key already exists" error would be logged. This message makes it easier to identify the issue.
This commit is contained in:
@@ -16,9 +16,9 @@ namespace Orchard.Recipes.Providers.Executors {
|
|||||||
private readonly ITransactionManager _transactionManager;
|
private readonly ITransactionManager _transactionManager;
|
||||||
|
|
||||||
public RecipesStep(
|
public RecipesStep(
|
||||||
IRecipeHarvester recipeHarvester,
|
IRecipeHarvester recipeHarvester,
|
||||||
IRecipeStepQueue recipeStepQueue,
|
IRecipeStepQueue recipeStepQueue,
|
||||||
IRepository<RecipeStepResultRecord> recipeStepResultRecordRepository,
|
IRepository<RecipeStepResultRecord> recipeStepResultRecordRepository,
|
||||||
ITransactionManager transactionManager,
|
ITransactionManager transactionManager,
|
||||||
RecipeExecutionLogger logger) : base(logger) {
|
RecipeExecutionLogger logger) : base(logger) {
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ namespace Orchard.Recipes.Providers.Executors {
|
|||||||
if (!recipes.ContainsKey(recipeName))
|
if (!recipes.ContainsKey(recipeName))
|
||||||
throw new Exception(String.Format("No recipe named '{0}' was found in extension '{1}'.", recipeName, extensionId));
|
throw new Exception(String.Format("No recipe named '{0}' was found in extension '{1}'.", recipeName, extensionId));
|
||||||
|
|
||||||
EnqueueRecipe(session, context.ExecutionId, recipes[recipeName]);
|
EnqueueRecipe(context.ExecutionId, recipes[recipeName]);
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
Logger.Error(ex, "Error while executing recipe '{0}' in extension '{1}'.", recipeName, extensionId);
|
Logger.Error(ex, "Error while executing recipe '{0}' in extension '{1}'.", recipeName, extensionId);
|
||||||
@@ -63,7 +63,7 @@ namespace Orchard.Recipes.Providers.Executors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EnqueueRecipe(ISession session, string executionId, Recipe recipe) {
|
private void EnqueueRecipe(string executionId, Recipe recipe) {
|
||||||
foreach (var recipeStep in recipe.RecipeSteps) {
|
foreach (var recipeStep in recipe.RecipeSteps) {
|
||||||
_recipeStepQueue.Enqueue(executionId, recipeStep);
|
_recipeStepQueue.Enqueue(executionId, recipeStep);
|
||||||
_recipeStepResultRecordRepository.Create(new RecipeStepResultRecord {
|
_recipeStepResultRecordRepository.Create(new RecipeStepResultRecord {
|
||||||
@@ -76,7 +76,12 @@ namespace Orchard.Recipes.Providers.Executors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IDictionary<string, Recipe> HarvestRecipes(string extensionId) {
|
private IDictionary<string, Recipe> HarvestRecipes(string extensionId) {
|
||||||
return _recipeHarvester.HarvestRecipes(extensionId).ToDictionary(x => x.Name);
|
try {
|
||||||
|
return _recipeHarvester.HarvestRecipes(extensionId).ToDictionary(x => x.Name);
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex) {
|
||||||
|
throw new OrchardFatalException(T("A recipe with the same name has been detected for extension \"{0}\". Please make sure recipes are uniquely named.", extensionId), ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user