Skip to content

Commit

Permalink
Fixes #223, no error message when parent node corresponding to MvcSit…
Browse files Browse the repository at this point in the history
…eMapNodeAttribute.ParentKey is not found in the SiteMap.
  • Loading branch information
NightOwl888 committed Sep 4, 2013
1 parent 168fc15 commit 85ff849
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ protected virtual ISiteMapNode CreateNodesFromMvcSiteMapNodeAttributeDefinitions
{
if (string.IsNullOrEmpty(assemblyNode.SiteMapNodeAttribute.ParentKey))
{
throw new MvcSiteMapException(string.Format(Resources.Messages.NoParentKeyDefined, nodeToAdd.Controller, nodeToAdd.Action));
throw new MvcSiteMapException(string.Format(Resources.Messages.NoParentKeyDefined, this.siteMapCacheKey, nodeToAdd.Controller, nodeToAdd.Action));
}

var parentForNode = parentNode != null ? siteMap.FindSiteMapNodeFromKey(assemblyNode.SiteMapNodeAttribute.ParentKey) : null;
Expand Down Expand Up @@ -300,19 +300,21 @@ protected virtual ISiteMapNode CreateNodesFromMvcSiteMapNodeAttributeDefinitions
}

// Process list of nodes that did not have a parent defined.
// If this does not succeed at this time, parent will default to root node.
// If this does not succeed at this time, an exception will be thrown.
if (parentNode != null)
{
foreach (var nodeToAdd in nodesToProcessLater)
{
var parentForNode = siteMap.FindSiteMapNodeFromKey(nodeToAdd.Value);
if (parentForNode == null)
{
var temp = nodesToProcessLater.Keys.Where(t => t.Key == nodeToAdd.Value).FirstOrDefault();
if (temp != null)
{
parentNode = temp;
}
throw new MvcSiteMapException(
String.Format(
Resources.Messages.ReflectionSiteMapBuilderParentNodeNotFound,
nodeToAdd.Value,
this.SiteMapCacheKey,
nodeToAdd.Key.Controller,
nodeToAdd.Key.Action));
}
if (parentForNode != null)
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
<value>Multiple nodes with the same URL '{0}' were found. SiteMap requires that sitemap nodes have unique URLs.</value>
</data>
<data name="NoParentKeyDefined" xml:space="preserve">
<value>Multiple root nodes defined. Are you missing a ParentKey definition on the '{0}' controller, '{1}'?</value>
<value>Multiple root nodes defined in sitemap with cache key '{0}'. Are you missing a ParentKey definition on the '{1}' controller, '{2}' method?</value>
</data>
<data name="NamedUrlResolverNotFound" xml:space="preserve">
<value>The URL resolver instance named '{0}' was not found. Check your DI configuration to ensure a URL resolver instance with this name exists and is configured correctly.</value>
Expand Down Expand Up @@ -223,4 +223,9 @@ PreservedRouteParameters always copies the route value from the current HTTP req

Alternatively, if you are configuring the node in XML and intend to use '{1}' as a custom attribute, use the 'MvcSiteMapProvider_AttributesToIgnore' configuration setting to ensure '{1}' is not automatically added to RouteValues. If using external DI, this setting is injected into the constructor of 'SiteMapXmlReservedAttributeNameProvider'.</value>
</data>
<data name="ReflectionSiteMapBuilderParentNodeNotFound" xml:space="preserve">
<value>The parent node with key '{0}' was not found in the sitemap with cache key '{1}' for the MvcSiteMapNodeAttribute defined on '{2}' controller, '{3}' method. The most likely cause is that the key property for the parent node was not set explicitly in your node configuration or it does not match the ParentKey that was set on '{2}' controller, '{3}' method.

This error can also happen if the 'Order' property for MvcSiteMapAttribute definitions has not been specified. Be sure the 'Order' for each parent node is lower than the 'Order' for its child nodes.</value>
</data>
</root>

0 comments on commit 85ff849

Please sign in to comment.