aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/firrtl/annotations/AnnotationUtils.scala
diff options
context:
space:
mode:
authorJack Koenig2018-03-22 11:53:51 -0700
committerGitHub2018-03-22 11:53:51 -0700
commitebb6847e9d01b424424ae11a0067448a4094e46d (patch)
treefc87aa9d7b7d437914f6a4c9e20487c0973a1fc3 /src/main/scala/firrtl/annotations/AnnotationUtils.scala
parent6ea4ac666e4ce8dfaca1545660f372fccff610f5 (diff)
Better bad annotation file error reporting (#771)
* Propagate exceptions from JsonProtocol deserialization * Add AnnotationFileNotFoundException for better error reporting * Add AnnotationClassNotFoundException for better error reporting * Better propagate JSON parsing errors Also report the file if there is a error deserializing a JSON file * Make exception for non-array JSON file more explicit
Diffstat (limited to 'src/main/scala/firrtl/annotations/AnnotationUtils.scala')
-rw-r--r--src/main/scala/firrtl/annotations/AnnotationUtils.scala12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main/scala/firrtl/annotations/AnnotationUtils.scala b/src/main/scala/firrtl/annotations/AnnotationUtils.scala
index 6b7f9a60..517cea26 100644
--- a/src/main/scala/firrtl/annotations/AnnotationUtils.scala
+++ b/src/main/scala/firrtl/annotations/AnnotationUtils.scala
@@ -3,6 +3,8 @@
package firrtl
package annotations
+import java.io.File
+
import org.json4s._
import org.json4s.native.JsonMethods._
import org.json4s.native.Serialization
@@ -14,7 +16,15 @@ import firrtl.annotations.AnnotationYamlProtocol._
import firrtl.ir._
import firrtl.Utils.error
-class InvalidAnnotationFileException(msg: String) extends FIRRTLException(msg)
+case class InvalidAnnotationFileException(file: File, cause: Throwable = null)
+ extends FIRRTLException(s"$file, see cause below", cause)
+case class InvalidAnnotationJSONException(msg: String) extends FIRRTLException(msg)
+case class AnnotationFileNotFoundException(file: File) extends FIRRTLException(
+ s"Annotation file $file not found!"
+)
+case class AnnotationClassNotFoundException(className: String) extends FIRRTLException(
+ s"Annotation class $className not found! Please check spelling and classpath"
+)
object AnnotationUtils {
def toYaml(a: LegacyAnnotation): String = a.toYaml.prettyPrint