Class J3DError

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
EngineException, GenericIOException, GenException, InteractionException, ThreadsException

public class J3DError extends RuntimeException
J3Engine Exceptions

It extends RuntimeException and provides structured error codes consisting of a base code and a specific error code, along with a formatted string representation of the error.

Author:
Lehlogonolo Poole
See Also:
  • Field Details

    • code

      int code
      A specific error code within the baseCode category. This code is typically set via the code(int) method.
    • baseCode

      private int baseCode
      The base category code for this error. This helps categorize errors into broader groups.
  • Constructor Details

    • J3DError

      public J3DError(String message, int baseCode)
      Constructs a new J3DError with the specified detail message and base code. The cause is not initialized, and the specific error code defaults to 0.
      Parameters:
      message - The detail message (which is saved for later retrieval by the Throwable.getMessage() method).
      baseCode - The base category code for this error.
    • J3DError

      public J3DError(String message, Throwable cause, int baseCode)
      Constructs a new J3DError with the specified detail message, cause, and base code. The specific error code defaults to 0.
      Parameters:
      message - The detail message (which is saved for later retrieval by the Throwable.getMessage() method).
      cause - The cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
      baseCode - The base category code for this error.
  • Method Details

    • code

      public J3DError code(int value)
      Sets the specific error code for this J3DError. This method allows for fluent API chaining.
      Parameters:
      value - The specific error code.
      Returns:
      This J3DError instance, allowing method chaining.
    • getCode

      public int getCode()
      Returns the specific error code associated with this J3DError.
      Returns:
      The specific error code.
    • getBaseCode

      public int getBaseCode()
      Returns the base category code associated with this J3DError.
      Returns:
      The base category code.
    • buildCode

      public int buildCode()
      Builds and returns a combined integer error code by multiplying the baseCode by 1000 and adding the code. This creates a unique numerical identifier for the error.
      Returns:
      The combined integer error code.
    • errorCode

      public String errorCode()
      Returns a formatted string representation of the error code. The format is "J" followed by the buildCode() padded to 5 digits with leading zeros. For example, if baseCode is 1 and code is 23, buildCode() would be 1023, and errorCode() would return "J01023".
      Returns:
      A string representing the formatted error code.