Package com.j3d.errors
Class ErrorHandler
java.lang.Object
com.j3d.errors.ErrorHandler
Centralized error handling mechanism for J3Engine.
This class provides methods to handle various types of J3DErrors,
categorising them by their severity (mild, warning, fatal) and performing
appropriate actions such as logging, displaying user messages, or
terminating the application. It also supports temporarily ignoring
specific error types.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidHandles a givenJ3DError, processing it based on its type and severity.voidhandleThenThrow(J3DError err) Handles a givenJ3DErrorusing thehandle(J3DError)method and then re-throws it.<T extends J3DError>
voidRegisters a specificJ3DErrorclass to be ignored by the error handler.
-
Field Details
-
ignored
-
-
Constructor Details
-
ErrorHandler
public ErrorHandler()
-
-
Method Details
-
ignore
Registers a specificJ3DErrorclass to be ignored by the error handler. When an error of the registered class type is encountered by thehandle(J3DError)method, it will be consumed (removed from the ignore list) and no further action will be taken. This effectively makes the next occurrence of that specific error type to be silently handled.- Type Parameters:
T- The type ofJ3DErrorto ignore.- Parameters:
err- TheClassobject of theJ3DErrorto be ignored.- Throws:
RuntimeException- if more than 10 error classes are attempted to be ignored.
-
handle
Handles a givenJ3DError, processing it based on its type and severity.If the error is registered to be ignored, that is handled
Otherwise, the error is processed based on its specific type:
J3DMild: The error is printed to the application's log.J3DWarning: The error is printed to the application's log, and a warning message dialogue is displayed to the user.J3DFatal: The error is printed to the application's log, and a fatal error message dialogue is displayed to the user. If the fatal error'sterminate()method returns true, an additional message is shown, and the application is terminated viaSystem.exit(1).- Any other
J3DErrortype (that is also an instance ofJ3ErrSeverity): The error is simply printed to the application's log.
- Parameters:
err- TheJ3DErrorinstance to be handled.
-
handleThenThrow
Handles a givenJ3DErrorusing thehandle(J3DError)method and then re-throws it.- Parameters:
err- TheJ3DErrorinstance to be handled and thrown.- Throws:
J3DError- The sameJ3DErrorinstance that was passed in, after it has been processed by thehandle(J3DError)method.
-