This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
Better error when TagHelperOutputExtensions.CopyHtmlAttribute()
called with unknown attributeName
#1586
Closed
Description
If the provided TagHelperContext
does not contain attributeName
, tag helper authors get very little information on how to fix the problem. Should improve the error message and help these authors out.
Details: An example of the current error:
System.InvalidOperationException : Sequence contains no matching element
Stack Trace:
at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
at Microsoft.AspNet.Mvc.TagHelpers.TagHelperOutputExtensions.CopyHtmlAttribute(TagHelperOutput tagHelperOutput, String attributeName, TagHelperContext context) in C:\dd\k\Mvc.0\src\Microsoft.AspNet.Mvc.TagHelpers\TagHelperOutputExtensions.cs:line 33
at Microsoft.AspNet.Mvc.TagHelpers.InputTagHelper.Process(TagHelperContext context, TagHelperOutput output) in C:\dd\k\Mvc.0\src\Microsoft.AspNet.Mvc.TagHelpers\InputTagHelper.cs:line 114
at Microsoft.AspNet.Razor.Runtime.TagHelpers.TagHelper.<ProcessAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
...
Could perhaps use FirstOrDefault()
and throw
a better Exception
if that returns null
.