Class ArgsSyntaxException

All Implemented Interfaces:
Serializable, ArgsAccessor, MatchCountAccessor, org.refcodes.exception.ErrorCodeAccessor, org.refcodes.exception.Trap, org.refcodes.mixin.SourceAccessor<Term>
Direct Known Subclasses:
AmbiguousArgsException, ParseArgsException, SuperfluousArgsException, UnknownArgsException

public class ArgsSyntaxException extends CliException.ConsoleArgsException implements org.refcodes.mixin.SourceAccessor<Term>, MatchCountAccessor
Thrown in case of a command line arguments mismatch regarding provided and expected args.
See Also:
  • Constructor Details

    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage, Term aSource)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
      aSource - The Term responsible for this exception (source).
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage, String aErrorCode, Term aSource)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
      aErrorCode - The error code identifying this exception.
      aSource - The Term responsible for this exception (source).
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage, Throwable aCause, Term aSource)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
      aCause - The Throwable (Exception) causing this exception.
      aSource - The Term responsible for this exception (source).
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage, Throwable aCause, String aErrorCode, Term aSource)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
      aCause - The Throwable (Exception) causing this exception.
      aErrorCode - The error code identifying this exception.
      aSource - The Term responsible for this exception (source).
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, Throwable aCause, Term aSource)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aCause - The Throwable (Exception) causing this exception.
      aSource - The Term responsible for this exception (source).
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, Throwable aCause, String aErrorCode, Term aSource)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aCause - The Throwable (Exception) causing this exception.
      aErrorCode - The error code identifying this exception.
      aSource - The Term responsible for this exception (source).
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage, String aErrorCode)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
      aErrorCode - The error code identifying this exception.
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage, Throwable aCause)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
      aCause - The Throwable (Exception) causing this exception.
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, String aMessage, Throwable aCause, String aErrorCode)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aMessage - The aMessage describing this exception.
      aCause - The Throwable (Exception) causing this exception.
      aErrorCode - The error code identifying this exception.
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, Throwable aCause)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aCause - The Throwable (Exception) causing this exception.
    • ArgsSyntaxException

      public ArgsSyntaxException(String[] aArgs, Throwable aCause, String aErrorCode)
      Instantiates a new ArgsSyntaxException exception.
      Parameters:
      aArgs - The arguments participating in the exception.
      aCause - The Throwable (Exception) causing this exception.
      aErrorCode - The error code identifying this exception.
  • Method Details

    • getMatchCount

      public int getMatchCount()
      Determines the number of args being matched upon encountering this exception.
      Specified by:
      getMatchCount in interface MatchCountAccessor
      Returns:
      The number of args matching till this exception occurred.
    • getSource

      public Term getSource()
      Returns the Term responsible for this exception.
      Specified by:
      getSource in interface org.refcodes.mixin.SourceAccessor<Term>
      Returns:
      The Term where this exception occurred.
    • toHeuristicMessage

      public String toHeuristicMessage()
      Tries to determine the most likely cause of this exception by crawling the exception tree down the causes and suppressed exceptions and evaluating their Term source's Term.getMatchCount() argument match counts. Throwable.getSuppressed() exceptions, the cause Throwable.getCause() is at a CHILD level of THIS exception, the cause's suppressed exceptions are at the SAME level as the cause itself. A wrong idea of the hierarchy of exceptions has erroneously been implemented, this implementation got to corrected as described.
      Returns:
      The heuristic cause of this exception.
    • toRootMatchCause

      public ArgsSyntaxException toRootMatchCause()
      Determines the root cause of this exception with the same match count (getMatchCount()) as this exception.
      Returns:
      The actual root cause of this exception or this exception if no (more specific) root cause was determined.