Brightspace / render-docs-action

A GitHub Action to render docs for https://docs.d2l.dev
Apache License 2.0
1 stars 0 forks source link

Improve error reporting when not exactly one level-1 header #51

Closed mthjones closed 3 years ago

mthjones commented 4 years ago

When there are no or multiple level-1 headers parsed, the renderer fails with the following stacktrace:

 Unhandled exception: System.InvalidOperationException: Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source, Func`2 predicate)
   at D2L.Dev.Docs.Render.Program.GetTitle(MarkdownDocument doc) in /render/src/Render/Program.cs:line 91
   at D2L.Dev.Docs.Render.Program.DoFile(DocumentContext context, RelativeFile file) in /render/src/Render/Program.cs:line 54
   at D2L.Dev.Docs.Render.Program.Main(String input, String output) in /render/src/Render/Program.cs:line 35

Catching this error (or handling it with SingleOrDefault) and outputting a nicer error message would help users understand what's wrong with their docs and fix it themselves.

Related issue: #9