Class RichErrorMessages

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

public final class RichErrorMessages extends Object
Provides rich error messages for AI-assisted development. These detailed messages are appended to error output when error level E3 is enabled, helping AI assistants understand and resolve EK9 compilation errors more effectively.

This class is a pure lookup - it contains no state. The decision of whether to based on the per-compilation error level from CompilerFlags.

Messages are loaded from individual .txt resource files in richErrorMessages/, listed by richErrorMessages/rich-error-manifest.txt. This allows researchers to create alternative message packs without modifying Java code.

Each error code has a rich message containing:

  • DIAGNOSIS - what went wrong
  • ACTION - steps to resolve
  • SEE ALSO - related errors and docs
  • Method Details

    • loadMessagePack

      public static void loadMessagePack(Path zipPath)
      Load alternative rich error messages from a message pack zip file. Messages in the pack override built-in messages; codes not in the pack fall back to the built-in defaults.
      Parameters:
      zipPath - path to the message pack zip file
    • getRichMessage

      public static String getRichMessage(String errorCode)
      Get the rich message for an error code. Checks the override pack first, then falls back to built-in messages.
      Parameters:
      errorCode - The error code (e.g., "E50001")
      Returns:
      The rich message, or null if not found
    • resetOverrides

      public static void resetOverrides()
      Reset overrides back to empty (for testing).