package com.abusalimov.mrcalc.diagnostic;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * DiagnosticException wraps an immutable list of {@link Diagnostic}s.
 *
 * @author Eldar Abusalimov
 */
public class DiagnosticException extends Exception {
    private final List<Diagnostic> diagnostics;

    public DiagnosticException(Diagnostic... diagnostic) {
        this.diagnostics = Arrays.asList(diagnostic);
    }

    public DiagnosticException(List<Diagnostic> diagnostics) {
        this.diagnostics = new ArrayList<>(diagnostics);
    }

    public DiagnosticException(Throwable cause) {
        this();
        initCause(cause);
    }

    public DiagnosticException(Diagnostic diagnostic, Throwable cause) {
        this(diagnostic);
        initCause(cause);
    }

    public DiagnosticException(List<Diagnostic> diagnostics, Throwable cause) {
        this(diagnostics);
        initCause(cause);
    }

    public Diagnostic getFirstDiagnostic() {
        if (diagnostics.isEmpty()) {
            return null;
        }
        return diagnostics.get(0);
    }

    public List<Diagnostic> getDiagnostics() {
        return Collections.unmodifiableList(diagnostics);
    }
}

@@ -1242,11 +1242,147 @@
 );%0A    %7D
+%0A%0A    @Override%0A    public String toString() %7B%0A        return String.format(%22%25s %7Bdiagnostics=%25s%7D%22, super.toString(), diagnostics);%0A    %7D
 %0A%7D%0A

Add DiagnosticException.toString()