Class TypesNotComparableException

All Implemented Interfaces:
Serializable

public class TypesNotComparableException extends DRException
Unchecked exception thrown when an attempt is made to compare two typed objects of incompatible types.

Exception chaining is used in two ways to provide additional details about the cause of a comparison error.

  • In the case of a record type, the exception may contain a FieldTypesNotComparableException as the cause indicating which fields raised the error.
  • Exceptions thrown from operators may contain another TypesNotComparableException. The wrapping exception contains more contextual information about the comparison performed.
See Also:
  • Constructor Details

    • TypesNotComparableException

      public TypesNotComparableException(TokenType leftType, TokenType rightType)
      Constructs a TypesNotComparableException indicating the specified types were compared.
      Parameters:
      leftType - the type of the object on the left side of the comparison
      rightType - the type of the object on the right side of the comparison
    • TypesNotComparableException

      public TypesNotComparableException(TokenType leftType, TokenType rightType, String reason)
      Constructs a TypesNotComparableException indicating the specified types were compared, providing additional information about the failure.
      Parameters:
      leftType - the type of the object on the left side of the comparison
      rightType - the type of the object on the right side of the comparison
      reason - an additional explanation of why the types are not comparable
    • TypesNotComparableException

      public TypesNotComparableException(RecordTokenType leftType, RecordTokenType rightType, FieldTypesNotComparableException cause)
      Constructs a TypesNotComparableException indicating the specified record types are not comparable due to underlying fields not being comparable.
      Parameters:
      leftType - the record type of the object on the left side of the comparison
      rightType - the record type of the object on the right side of the comparison
      cause - the underlying field exception
    • TypesNotComparableException

      public TypesNotComparableException(String context, TypesNotComparableException cause)
      Constructs a TypesNotComparableException providing additional context
      Parameters:
      context - a message providing additional context for the exception
      cause - the wrapped exception
  • Method Details

    • getMessage

      public String getMessage()
      Overrides:
      getMessage in class Throwable
    • getLeftType

      public TokenType getLeftType()
      Gets the type of the object on the left side of the comparison which raised this exception.
      Returns:
      the type of object on the left side of the comparison
    • getRightType

      public TokenType getRightType()
      Gets the type of the object on the right side of the comparison which raised this exception.
      Returns:
      the type of object on the right side of the comparison