aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/annotations/JsonProtocol.scala
diff options
context:
space:
mode:
authorJack Koenig2019-08-19 23:45:07 -0700
committerGitHub2019-08-19 23:45:07 -0700
commitd1a682f47935009215f56664cefae0de26e2eabf (patch)
tree2dac347abf87dcfd0018cb4e42d563c2bd78050d /src/main/scala/firrtl/annotations/JsonProtocol.scala
parent0f6b9615213a2a9770974ff71b3da3f6b770a772 (diff)
Refactor exceptions to remove stack trace from user errors (#1157)
Diffstat (limited to 'src/main/scala/firrtl/annotations/JsonProtocol.scala')
-rw-r--r--src/main/scala/firrtl/annotations/JsonProtocol.scala7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/main/scala/firrtl/annotations/JsonProtocol.scala b/src/main/scala/firrtl/annotations/JsonProtocol.scala
index 5270c26f..b09155d8 100644
--- a/src/main/scala/firrtl/annotations/JsonProtocol.scala
+++ b/src/main/scala/firrtl/annotations/JsonProtocol.scala
@@ -37,7 +37,7 @@ object JsonProtocol {
try {
Class.forName(s).asInstanceOf[Class[_ <: Transform]].newInstance()
} catch {
- case e: java.lang.InstantiationException => throw new FIRRTLException(
+ case e: java.lang.InstantiationException => throw new FirrtlInternalException(
"NoSuchMethodException during construction of serialized Transform. Is your Transform an inner class?", e)
case t: Throwable => throw t
}},
@@ -113,10 +113,11 @@ object JsonProtocol {
// Translate some generic errors to specific ones
case e: java.lang.ClassNotFoundException =>
Failure(new AnnotationClassNotFoundException(e.getMessage))
- case e: org.json4s.ParserUtil.ParseException =>
+ // Eat the stack traces of json4s exceptions
+ case e @ (_: org.json4s.ParserUtil.ParseException | _: org.json4s.MappingException) =>
Failure(new InvalidAnnotationJSONException(e.getMessage))
}.recoverWith { // If the input is a file, wrap in InvalidAnnotationFileException
- case e => in match {
+ case e: FirrtlUserException => in match {
case FileInput(file) =>
Failure(new InvalidAnnotationFileException(file, e))
case _ => Failure(e)