diff options
| author | Jack Koenig | 2020-05-22 12:13:08 -0700 |
|---|---|---|
| committer | Jack Koenig | 2020-05-22 16:50:15 -0700 |
| commit | db7928a44e737222524519be9d9b1cf3b2d7804a (patch) | |
| tree | ed217aac5cf13c7da710294214c7182dbb2c58e0 /src/main | |
| parent | 1930b7b0655028bd81707d8cfefba2310d3a1bbb (diff) | |
Do not throw NonFatal exceptions in annotation logging
If an annotation cannot be serialized by json4s, we should not throw
exceptions when doing trace-level logging.
Diffstat (limited to 'src/main')
| -rw-r--r-- | src/main/scala/firrtl/Compiler.scala | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/Compiler.scala b/src/main/scala/firrtl/Compiler.scala index 5a7dd4c8..6f921189 100644 --- a/src/main/scala/firrtl/Compiler.scala +++ b/src/main/scala/firrtl/Compiler.scala @@ -6,6 +6,8 @@ import logger._ import java.io.Writer import scala.collection.mutable +import scala.util.Try +import scala.util.control.NonFatal import firrtl.annotations._ import firrtl.ir.Circuit @@ -211,7 +213,14 @@ private[firrtl] object Transform { logger.info(s"Form: ${after.form}") logger.trace(s"Annotations:") - logger.trace(JsonProtocol.serialize(remappedAnnotations)) + logger.trace { + JsonProtocol.serializeTry(remappedAnnotations).recoverWith { + case NonFatal(e) => + val msg = s"Exception thrown during Annotation serialization:\n " + + e.toString.replaceAll("\n", "\n ") + Try(msg) + }.get + } logger.trace(s"Circuit:\n${after.circuit.serialize}") logger.info(s"======== Finished Transform $name ========\n") |
