1 package org.simantics.scl.compiler.errors;
3 import java.io.PrintStream;
5 @SuppressWarnings("rawtypes")
6 public class Failure implements Failable {
7 public final CompilationError[] errors;
9 public Failure(CompilationError[] errors) {
13 public Failure(String description) {
14 this.errors = new CompilationError[] { new CompilationError(description) };
17 public Failure(Exception e) {
18 this.errors = new CompilationError[] { new CompilationError(e) };
21 public void printTo(PrintStream out) {
22 for(CompilationError error : errors)
23 out.println(error.description);
26 public String toString(String source) {
27 return CompilationErrorFormatter.toString(source, errors);
31 public String toString() {
32 return CompilationErrorFormatter.toString(errors);
36 public Object getResult() {
37 throw new IllegalStateException("Module compilation failed.");
41 public boolean didSucceed() {
46 public String getDescription() {
47 StringBuilder b = new StringBuilder();
48 b.append("Module compilation failed:");
49 for(CompilationError error : errors)
50 b.append("\n ").append(error.description);