Class TreeException

java.lang.Object
java.lang.Throwable
java.lang.Exception
com.madzera.happytree.exception.TreeException
All Implemented Interfaces:
Serializable

public class TreeException extends Exception
The class TreeException represents a checked exception for the HappyTree API by inheriting the Exception class.

The TreeException is the only checked exception class that can be thrown by this API. This happens when the following validations are not met:

  • When there is another session with the same identifier while initializing a new session;
  • When the class of the object to be transformed has not been annotated with @Tree, @Id, and @Parent when initializing a new session;
  • When the annotated attributes @Id and @Parent have different types;
  • When the transaction has no session selected to work on;
  • When the current session is not active;
  • When there are mismatched parameterized types when invoking operations;
  • When there is an attempt to handle an element that does not belong to the current session;
  • When there is an attempt to handle the root element of the tree;
  • When the element to be cut/copied/removed is not in the ATTACHED state in its lifecycle;
  • When the element to be updated is in the NOT_EXISTED state in its lifecycle;
  • When the element to be persisted is not in the NOT_EXISTED state in its lifecycle;
  • When there is an Element object with a duplicate @Id while trying to insert/update or cut/copy an element between trees;
Author:
Diego Madson de Andrade Nóbrega
See Also:
  • Constructor Details

    • TreeException

      public TreeException()
      Default constructor for this exception. This invocation implies a null detail message for the exception as well as a null cause.

      To initialize a cause, invoke Throwable.initCause(Throwable).

    • TreeException

      public TreeException(String message)
      This constructor allows specifying a detail message for the exception when it is thrown. In this case, the cause of the exception is null.

      To initialize a cause, invoke Throwable.initCause(Throwable).

      Parameters:
      message - the detail message of the exception
    • TreeException

      public TreeException(Throwable cause)
      Creates an exception with the specified cause. In this case, the message of the exception will be the message associated with the cause parameter.
      Parameters:
      cause - the cause of the exception
    • TreeException

      public TreeException(String message, Throwable cause)
      Creates an exception with the specified message and cause. In this case, the exception will have the detail message set by the message parameter and the cause parameter as the Throwable.initCause(Throwable).
      Parameters:
      message - the detail message of the exception
      cause - the cause of the exception