Java Diagnostic to Output raiseCompilerError(String error)

Here you can find the source of raiseCompilerError(String error)

Description

Raises a fatal compiler error with the given message, halting execution.

License

Open Source License

Parameter

Parameter Description
error The error string to display.

Declaration

private static void raiseCompilerError(String error) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.annotation.processing.ProcessingEnvironment;
import javax.tools.Diagnostic;

import java.util.Arrays;

public class Main {
    private static ProcessingEnvironment processingEnv;

    /**/*from   w ww  .j a v  a2s  .  c om*/
     * Raises a fatal compiler error with the given message, halting execution.
     *
     * @param error The error string to display.
     */
    private static void raiseCompilerError(String error) {
        // In the case we're aborting before the environment is available...
        if (processingEnv == null) {
            return;
        }

        processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, "Fatal error from optimiser: " + error
                + "\nAt:\n" + Arrays.toString(new Exception().getStackTrace()).replace(',', '\n'));
    }
}

Related

  1. diagnosticToString(final Diagnostic diagnostic, boolean usingAnomsgtxt)
  2. errorsToString( DiagnosticCollector diagnosticCollector)
  3. filterSupportedSourceVersionWarnings( List> diagnostics)
  4. log(ProcessingEnvironment processingEnvironment, Diagnostic.Kind kind, CharSequence message)
  5. note(final ProcessingEnvironment processingEnv, final String message, final Object... args)