diff options
| author | Jack Koenig | 2020-09-04 17:20:01 -0700 |
|---|---|---|
| committer | GitHub | 2020-09-05 00:20:01 +0000 |
| commit | 47c81ee3e68c96e94dafa389cb53b162e996a4df (patch) | |
| tree | e976c5b9adcec16a6215863eda811617c64c5f1c /src/main/scala/firrtl/annotations/AnnotationUtils.scala | |
| parent | b25c90f27bcf5ff61d7f0d16fb274759a628a500 (diff) | |
Better error messages for unserializable annotations (#1885)
Diffstat (limited to 'src/main/scala/firrtl/annotations/AnnotationUtils.scala')
| -rw-r--r-- | src/main/scala/firrtl/annotations/AnnotationUtils.scala | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/annotations/AnnotationUtils.scala b/src/main/scala/firrtl/annotations/AnnotationUtils.scala index a1276e0e..eccb4e13 100644 --- a/src/main/scala/firrtl/annotations/AnnotationUtils.scala +++ b/src/main/scala/firrtl/annotations/AnnotationUtils.scala @@ -18,6 +18,16 @@ case class AnnotationClassNotFoundException(className: String) extends FirrtlUserException( s"Annotation class $className not found! Please check spelling and classpath" ) +class UnserializableAnnotationException private (msg: String) extends FirrtlUserException(msg) +object UnserializableAnnotationException { + private def toMessage(pair: (Annotation, Throwable)): String = + s"Failed to serialiaze annotation of type ${pair._1.getClass.getName} because '${pair._2.getMessage}'" + private[firrtl] def apply(badAnnos: Seq[(Annotation, Throwable)]) = { + require(badAnnos.nonEmpty) + val msg = badAnnos.map(toMessage).mkString("\n ", "\n ", "\n") + new UnserializableAnnotationException(msg) + } +} object AnnotationUtils { |
