Class MetapathException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
DynamicMetapathException, FunctionMetapathError, RegularExpressionMetapathException, StaticMetapathException, TypeMetapathException

public class MetapathException extends RuntimeException
MetapathException is the superclass of all exceptions that can be thrown during the compilation and evaluation of a Metapath.
See Also:
  • Constructor Details

    • MetapathException

      protected MetapathException(@NonNull IErrorCode errorCode, @Nullable String message)
      Constructs a new Metapath exception with the provided code and message and no cause.
      Parameters:
      errorCode - the error code that identifies the type of error
      message - the exception message
    • MetapathException

      protected MetapathException(@NonNull IErrorCode errorCode, @Nullable Throwable cause)
      Constructs a new Metapath exception with a null message and the provided code and cause.
      Parameters:
      errorCode - the error code that identifies the type of error
      cause - the exception cause
    • MetapathException

      protected MetapathException(@NonNull IErrorCode errorCode, @Nullable String message, @Nullable Throwable cause)
      Constructs a new Metapath exception with the provided code, message and cause.
      Parameters:
      errorCode - the error code that identifies the type of error
      message - the exception message
      cause - the exception cause
  • Method Details

    • registerEvaluationContext

      public final MetapathException registerEvaluationContext(@NonNull DynamicContext dynamicContext)
      Registers the evaluation context from the provided dynamic context.

      A snapshot of the execution stack is captured from the dynamic context if not already set. This ensures the recorded state reflects the stack at the time of registration, avoiding confusion from post-throw mutations.

      Parameters:
      dynamicContext - the dynamic context containing the execution stack
      Returns:
      this exception instance for chaining
    • registerEvaluationContext

      public final MetapathException registerEvaluationContext(@NonNull Deque<? extends IExpression> stack)
      Registers the evaluation context from the provided evaluation stack.

      A snapshot of the stack is captured if not already set.

      Parameters:
      stack - the evaluation stack recording the expressions being evaluated
      Returns:
      this exception instance for chaining
    • registerEvaluationContext

      public final MetapathException registerEvaluationContext(@NonNull IMetapathExpression metapath)
      Registers the evaluation context from the provided metapath expression.

      The expression is recorded as the evaluation context if not already set.

      Parameters:
      metapath - the metapath expression being evaluated
      Returns:
      this exception instance for chaining
    • getEvaluationStack

      @Nullable protected Deque<IExpression> getEvaluationStack()
      Retrieves the evaluation stack recording the expressions being evaluated.
      Returns:
      the evaluation stack, or null if not set
    • getMessage

      public final String getMessage()
      Overrides:
      getMessage in class Throwable
    • getMessageText

      @Nullable public String getMessageText()
      Get the message text without the error code prefix.
      Returns:
      the message text or null
    • getErrorCode

      @NonNull public final IErrorCode getErrorCode()
      Get the error code, which indicates what type of error it is.
      Returns:
      the error code