Package com.j3d.errors
Class J3DError
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
com.j3d.errors.J3DError
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
EngineException,GenericIOException,GenException,InteractionException,ThreadsException
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcode(int value) Sets the specific error code for thisJ3DError.Returns a formatted string representation of the error code.intReturns the base category code associated with thisJ3DError.intgetCode()Returns the specific error code associated with thisJ3DError.Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Field Details
-
code
int code -
baseCode
private int baseCodeThe base category code for this error. This helps categorize errors into broader groups.
-
-
Constructor Details
-
J3DError
Constructs a newJ3DErrorwith 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 theThrowable.getMessage()method).baseCode- The base category code for this error.
-
J3DError
Constructs a newJ3DErrorwith 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 theThrowable.getMessage()method).cause- The cause (which is saved for later retrieval by theThrowable.getCause()method). (Anullvalue is permitted, and indicates that the cause is nonexistent or unknown.)baseCode- The base category code for this error.
-
-
Method Details
-
code
Sets the specific error code for thisJ3DError. This method allows for fluent API chaining.- Parameters:
value- The specific error code.- Returns:
- This
J3DErrorinstance, allowing method chaining.
-
getCode
public int getCode()Returns the specific error code associated with thisJ3DError.- Returns:
- The specific error code.
-
getBaseCode
public int getBaseCode()Returns the base category code associated with thisJ3DError.- Returns:
- The base category code.
-
buildCode
public int buildCode()Builds and returns a combined integer error code by multiplying thebaseCodeby 1000 and adding thecode. This creates a unique numerical identifier for the error.- Returns:
- The combined integer error code.
-
errorCode
Returns a formatted string representation of the error code. The format is "J" followed by thebuildCode()padded to 5 digits with leading zeros. For example, ifbaseCodeis 1 andcodeis 23,buildCode()would be 1023, anderrorCode()would return "J01023".- Returns:
- A string representing the formatted error code.
-