restful-routing / restful-routing

A rails inspired restful routing api for asp .net mvc
http://restfulrouting.com
MIT License
146 stars 37 forks source link

Better Exception when modifying the collection in the wrong scope #61

Closed khalidabuhakmeh closed 11 years ago

khalidabuhakmeh commented 11 years ago

System.InvalidOperationException: Collection was modified; enumeration operation may not execute. This gets thrown when you are modifying the collection from within a scope. Example:

map.Area<AdjustmentsDashboardController>("dashboards", dashboards =>
{
        // Oooooops!!! Should be using dasbhoards and not map
    map.Path("adjustments").To<AdjustmentsDashboardController>(x => x.Index(null, null));
    map.Path("discounts").To<AdjustmentsDashboardController>(x => x.Index(null, null));
});

This is user error, but should probably give a more helpful exception.

[InvalidOperationException: Collection was modified; enumeration operation may not execute.] System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52 System.Collections.Generic.Enumerator.MoveNextRare() +10689337 System.Collections.Generic.Enumerator.MoveNext() +64 RestfulRouting.Mapper.RegisterRoutes(RouteCollection routeCollection) +143 RestfulRouting.RouteSet.RegisterRoutes(RouteCollection routes, String[] namespaces) +94 RestfulRouting.MapRoutesExtension.MapRoutes(RouteCollection routes, String[] namespaces) +111

friism commented 11 years ago

:+1:

khalidabuhakmeh commented 11 years ago

Totally accept a pull request for this by the way. :)

Kind Regards,

Khalid Abuhakmeh

On Jun 15, 2013, at 12:50 PM, Michael Friis notifications@github.com wrote:

— Reply to this email directly or view it on GitHub.

khalidabuhakmeh commented 11 years ago

Thanks to @TheCloudlessSky for this. It is out in version 1.4.5. Download it today.