diff options
Diffstat (limited to 'src/main/scala/Chisel/Error.scala')
| -rw-r--r-- | src/main/scala/Chisel/Error.scala | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/main/scala/Chisel/Error.scala b/src/main/scala/Chisel/Error.scala index c5fe4796..622d51a3 100644 --- a/src/main/scala/Chisel/Error.scala +++ b/src/main/scala/Chisel/Error.scala @@ -38,15 +38,10 @@ private object throwException { throw new ChiselException(s, t) } -/** This Singleton implements a log4j compatible interface. - It is used through out the Chisel package to report errors and warnings - detected at runtime. - */ -private object ChiselError { +/** Records and reports runtime errors and warnings. */ +private class ErrorLog { def hasErrors = errors.exists(_.isFatal) - def clear(): Unit = errors.clear - /** Log an error message */ def error(m: => String): Unit = errors += new Error(m, getUserLineNumber) @@ -57,7 +52,7 @@ private object ChiselError { /** Emit an informational message */ def info(m: String): Unit = - println(new Info(" [%2.3f] %s".format(elapsedTime/1e3, m), None)) + println(new Info("[%2.3f] %s".format(elapsedTime/1e3, m), None)) /** Prints error messages generated by Chisel at runtime. */ def report(): Unit = errors foreach println @@ -65,7 +60,7 @@ private object ChiselError { /** Throw an exception if any errors have yet occurred. */ def checkpoint(): Unit = if(hasErrors) { import Console._ - throw new IllegalStateException( + throwException(errors.map(_ + "\n").reduce(_+_) + UNDERLINED + "CODE HAS " + errors.filter(_.isFatal).length + RESET + UNDERLINED + " " + RED + "ERRORS" + RESET + UNDERLINED + " and " + errors.filterNot(_.isFatal).length + RESET + @@ -100,7 +95,7 @@ private abstract class LogEntry(msg: => String, line: Option[StackTraceElement]) override def toString: String = line match { case Some(l) => s"${format} ${l.getFileName}:${l.getLineNumber}: ${msg} in class ${l.getClassName}" - case None => s"${format}: ${msg}" + case None => s"${format} ${msg}" } protected def tag(name: String, color: String): String = |
