Class FormulaFormatException

All Implemented Interfaces:
Serializable

public class FormulaFormatException extends IllegalArgumentException
A compiled formula arriving over the wire is not a valid program.

This is a wire-format error, not a syntax error. A syntax error is a FormulaException and carries the offset and length of the offending span in the source text, because a human wrote that text and will be shown where it went wrong. There is no source text here and no human to show it to: the stream came from the other side of the connection, and the only useful questions are WHAT was wrong with it and whether the other side agrees that it was wrong.

Why a reason token and not just a message. The Golden Gate conformance corpus requires both implementations to refuse a malformed stream AND to refuse it FOR THE SAME REASON -- a codec that agrees on valid input and disagrees on invalid input is still a wire-format bug, because one side goes on to evaluate a stream the other refused and answers with a plausible wrong number rather than an error. Asserting that across two languages by matching message TEXT would couple the corpus to Java's wording and break on the first rephrasing. getReason() is a stable identifier; the message stays free to be as readable as it likes.

It extends IllegalArgumentException deliberately, so that every existing catch and every existing assertThrows(IllegalArgumentException.class, ...) keeps working unchanged; only code that wants the classification needs to know about this subclass.

Author:
Christopher Mindus
See Also:
  • Field Details

    • UNKNOWN_OPCODE

      public static final String UNKNOWN_OPCODE
      Reason: an opcode outside the flat space 1 to Op.OP_LAST.
      See Also:
    • STACK_UNDERFLOW

      public static final String STACK_UNDERFLOW
      Reason: an instruction whose operands are not on the stack.
      See Also:
    • STACK_NOT_ONE

      public static final String STACK_NOT_ONE
      Reason: a program that does not leave exactly one value on the stack.
      See Also:
    • STACK_TOO_DEEP

      public static final String STACK_TOO_DEEP
      Reason: a peak evaluation depth above Formula.MAX_STACK_DEPTH.

      The most consequential of the five on the client, where the evaluation stack is a fixed Float64Array allocated once and never bounds-checked at evaluation time. Writing past a typed array in JavaScript is a SILENT no-op, so without this check a too-deep program lays a component out at a wrong size with nothing reported anywhere.

      See Also:
    • CONSTANT_INDEX

      public static final String CONSTANT_INDEX
      Reason: a constant index out of order or out of range.
      See Also:
  • Constructor Details

    • FormulaFormatException

      public FormulaFormatException(String reason, String message)
      Creates the exception.
      Parameters:
      reason - The stable reason token, one of the constants of this class.
      message - The human-readable message.
  • Method Details