diff options
| author | azidar | 2016-05-24 10:17:51 -0700 |
|---|---|---|
| committer | jackkoenig | 2016-05-24 10:42:18 -0700 |
| commit | f9e8895b73aeec9bb71449f8e3d0e6f7e7a0a478 (patch) | |
| tree | 1b9384689555f4625ad7c24279a35b74071707ad /src/main/scala/firrtl/passes/Passes.scala | |
| parent | 243ff24f8eb9aae18bb0c7afe4f4c1e6cd66c084 (diff) | |
Added Errors class and fixed tests.
Canonicalizes catching/throwing PassExceptions.
Diffstat (limited to 'src/main/scala/firrtl/passes/Passes.scala')
| -rw-r--r-- | src/main/scala/firrtl/passes/Passes.scala | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/main/scala/firrtl/passes/Passes.scala b/src/main/scala/firrtl/passes/Passes.scala index bc11bc9d..c0d5327f 100644 --- a/src/main/scala/firrtl/passes/Passes.scala +++ b/src/main/scala/firrtl/passes/Passes.scala @@ -50,6 +50,17 @@ trait Pass extends LazyLogging { // Error handling class PassException(message: String) extends Exception(message) class PassExceptions(exceptions: Seq[PassException]) extends Exception("\n" + exceptions.mkString("\n")) +class Errors { + val errors = ArrayBuffer[PassException]() + def append(pe: PassException) = errors.append(pe) + def trigger = errors.size match { + case 0 => + case 1 => throw errors.head + case _ => + append(new PassException(s"${errors.length} errors detected!")) + throw new PassExceptions(errors) + } +} // These should be distributed into separate files object ToWorkingIR extends Pass { |
