Class Ek9FailureMarker

java.lang.Object
org.ek9lang.compiler.common.Ek9FailureMarker

public final class Ek9FailureMarker extends Object
THE marker line EK9 writes FIRST on stderr when EK9 ITSELF fails - the CLI, the compiler, or the generated ek9.Main entry point rejecting a program's arguments - e.g. ek9: compilation failed (exit 8). Use it; never format or parse the line elsewhere.

Why (Steve, 2026-10-05, decision C): a program's exit code shares the number space of Ek9ExitCodes. A program may return 3, 8 or 11 - scripts being replaced by EK9 programs need exactly the codes they had, and in production the compiled program runs without the ek9 wrapper - so no code can be reserved, and the number alone can never say whose it is. The marker can: a run whose first stderr line is a marker naming the same code as the exit failed in EK9; a program's own exit (normal, a returned Integer, an uncaught Exception's exitCode, a Panic) never carries one.

Writers: org.ek9lang.commands.CliStderr (the CLI process - it holds stderr so the marker can precede everything else) and MainClassGenerator (the program's entry point, which embeds of(int) as a constant: 9 and 10 for the arguments, and the CLI's own codes when it refuses its command line - 2 for '-r' with no name, 4 for a program it does not have, 6 for none named among several, 5 for none at all). Readers: the MCP runner (Ek9SubprocessTool, RunProgramTool) through firstLineCode(String) and withoutMarker(String).

  • Field Details

    • PREFIX

      public static final String PREFIX
      Every marker starts with this; it names the tool, as git: or javac: do.
      See Also:
  • Method Details

    • of

      public static String of(int exitCode)
      The marker for an EK9-owned failure exit, e.g. ek9: compilation failed (exit 8); null for 0 and 1 (not failures) and for any code EK9 does not own.
    • codeIn

      public static OptionalInt codeIn(String line)
      The code a line names when it is EXACTLY a marker (surrounding whitespace aside), else empty.
    • firstLineCode

      public static OptionalInt firstLineCode(String stderr)
      The code named by the FIRST line of a stderr capture when that line is a marker, else empty. Only the first line counts: a marker anywhere else was printed by something other than EK9.
    • withoutMarker

      public static String withoutMarker(String stderr)
      The stderr capture with a leading marker line removed (unchanged when there is none).