Enum Class CommandErrorCode

java.lang.Object
java.lang.Enum<CommandErrorCode>
io.axoniq.framework.springcloud.command.CommandErrorCode
All Implemented Interfaces:
Serializable, Comparable<CommandErrorCode>, Constable

public enum CommandErrorCode extends Enum<CommandErrorCode>
The kinds of failure a CommandDispatchReply can report, and the classification a receiving member needs to reconstruct an equivalent exception.

Failures cross the wire as a code rather than a serialized exception. Serializing exceptions would couple both ends to the same classes and versions, and would make the reply format a deserialization surface. A code plus a message conveys what the dispatching side actually needs: which kind of failure occurred, and whether retrying it can help.

Since:
5.4.0
Author:
Allard Buijze
  • Enum Constant Details

  • Method Details

    • values

      public static CommandErrorCode[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static CommandErrorCode valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • classify

      public static CommandErrorCode classify(Throwable cause)
      Classifies the given cause, raised while receiving or handling a command, into the code to report it under.

      The two specific kinds are recognised first, because both say something the generic execution codes do not: no handler exists yet, and the command never reached a handler at all. Only what is left is an execution failure, split by whether the application declared it worth retrying.

      Parameters:
      cause - the exception raised while receiving or handling a command
      Returns:
      NO_HANDLER_FOR_COMMAND when no handler was found, COMMAND_DISPATCH_ERROR when the command never reached a handler, COMMAND_EXECUTION_NON_TRANSIENT_ERROR when the given cause is explicitly non-transient, and COMMAND_EXECUTION_ERROR otherwise