Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Commit

Permalink
[Fixes #4991] Misleading MissingMethodException message for incorrect…
Browse files Browse the repository at this point in the history
… routes
  • Loading branch information
kichalla committed Aug 10, 2016
1 parent 0bb2c3c commit 5ddea57
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/Microsoft.AspNetCore.Mvc.Core/Internal/AttributeRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,24 @@ internal void AddEntries(TreeRouteBuilder builder, ActionDescriptorCollection ac
defaults.Add(kvp.Key, kvp.Value);
}

// We use the `NullRouter` as the route handler because we don't need to do anything for link
// generations. The TreeRouter does it all for us.
builder.MapOutbound(
NullRouter.Instance,
routeInfo.RouteTemplate,
defaults,
routeInfo.RouteName,
routeInfo.Order);
try
{
// We use the `NullRouter` as the route handler because we don't need to do anything for link
// generations. The TreeRouter does it all for us.
builder.MapOutbound(
NullRouter.Instance,
routeInfo.RouteTemplate,
defaults,
routeInfo.RouteName,
routeInfo.Order);
}
catch (RouteCreationException routeProcessingException)
{
throw new RouteCreationException(
"An error occurred while adding a route to the route builder. " +
$"Route name '{routeInfo.RouteName}' and template '{routeInfo.RouteTemplate.TemplateText}'.",
routeProcessingException);
}
}

// We're creating one AttributeRouteMatchingEntry per group, so we need to identify the distinct set of
Expand All @@ -113,7 +123,7 @@ internal void AddEntries(TreeRouteBuilder builder, ActionDescriptorCollection ac
var handler = _handlerFactory(group.ToArray());

// Note that because we only support 'inline' defaults, each routeInfo group also has the same
// set of defaults.
// set of defaults.
//
// We then inject the route group as a default for the matcher so it gets passed back to MVC
// for use in action selection.
Expand Down Expand Up @@ -227,7 +237,7 @@ private class RouteInfo
public ActionDescriptor ActionDescriptor { get; set; }

public string ErrorMessage { get; set; }

public int Order { get; set; }

public string RouteName { get; set; }
Expand Down

0 comments on commit 5ddea57

Please sign in to comment.