Skip to content

Commit 659f186

Browse files
committed
Do not fail when rendering briefs
In case of no paragraph or exception use '...'
1 parent dfe6f3e commit 659f186

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

scala3doc/src/dotty/dokka/site/LoadedTemplate.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,15 @@ case class LazyEntry(getKey: String, value: () => String) extends JMapEntry[Stri
2020
case class LoadedTemplate(templateFile: TemplateFile, children: List[LoadedTemplate], file: File):
2121

2222
private def brief(ctx: StaticSiteContext): String =
23-
val code = Jsoup.parse(resolveToHtml(ctx).code)
24-
code.select("p").first().outerHtml()
23+
try
24+
val code = Jsoup.parse(resolveToHtml(ctx).code)
25+
Option(code.select("p").first()).fold("...")(_.outerHtml())
26+
catch
27+
case e: Throwable =>
28+
// TODO (https://github.com/lampepfl/scala3doc/issues/238): provide proper error handling
29+
println(s"[ERROR] Unable to process brief for ${templateFile.file}")
30+
e.printStackTrace()
31+
"..."
2532

2633
def lazyTemplateProperties(ctx: StaticSiteContext): JMap[String, Object] = new java.util.AbstractMap[String, Object]():
2734
def entrySet(): JSet[JMapEntry[String, Object]] =

0 commit comments

Comments
 (0)