mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge pull request #5344 from gcsuk/5342
Added logging for invalid recipe files
This commit is contained in:
@@ -133,7 +133,8 @@ namespace Orchard.Modules.Controllers {
|
||||
Module = x,
|
||||
Recipes = _recipeHarvester.HarvestRecipes(x.Descriptor.Id).Where(recipe => !recipe.IsSetupRecipe).ToList()
|
||||
})
|
||||
.Where(x => x.Recipes.Any());
|
||||
.Where(x => x.Recipes.Any())
|
||||
.ToList();
|
||||
}
|
||||
|
||||
return View(viewModel);
|
||||
|
||||
@@ -35,10 +35,17 @@ namespace Orchard.Recipes.Services {
|
||||
if (extension != null) {
|
||||
var recipeLocation = Path.Combine(extension.Location, extensionId, "Recipes");
|
||||
var recipeFiles = _webSiteFolder.ListFiles(recipeLocation, true);
|
||||
recipes.AddRange(
|
||||
from recipeFile in recipeFiles
|
||||
where recipeFile.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase)
|
||||
select _recipeParser.ParseRecipe(_webSiteFolder.ReadFile(recipeFile)));
|
||||
|
||||
recipeFiles.Where(r => r.EndsWith(".recipe.xml", StringComparison.OrdinalIgnoreCase)).ToList().ForEach(r => {
|
||||
|
||||
try {
|
||||
recipes.Add(_recipeParser.ParseRecipe(_webSiteFolder.ReadFile(r)));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
Logger.Error(new Exception(string.Format("Invalid recipe file: {0}\nError: {1}", r, ex.Message)), "Invalid recipe file: {0}\nError: {1}", r, ex.Message);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
else {
|
||||
Logger.Error("Could not discover recipes because module '{0}' was not found.", extensionId);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Xml;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.Localization;
|
||||
@@ -21,10 +20,14 @@ namespace Orchard.Recipes.Services {
|
||||
var recipe = new Recipe();
|
||||
|
||||
try {
|
||||
|
||||
if (string.IsNullOrEmpty(recipeText)) {
|
||||
throw new Exception("Recipe is empty");
|
||||
}
|
||||
|
||||
XElement recipeTree = XElement.Parse(recipeText, LoadOptions.PreserveWhitespace);
|
||||
|
||||
var recipeSteps = new List<RecipeStep>();
|
||||
TextReader textReader = new StringReader(recipeText);
|
||||
var recipeTree = XElement.Load(textReader, LoadOptions.PreserveWhitespace);
|
||||
textReader.Close();
|
||||
|
||||
foreach (var element in recipeTree.Elements()) {
|
||||
// Recipe mETaDaTA
|
||||
|
||||
Reference in New Issue
Block a user