Chapter 3: Error Handling in Activerse
In this chapter, you'll learn how Activerse handles errors, the different types of errors in Java, and how the Activerse Concurrent Error Handling System (ACEHS) works to make debugging easier and more efficient.
The Basics of Errors
Let's first review the different types of errors in Java:
-
Compilation Error
When: During compilation.
What: Code doesn't follow syntax rules of the programming language (e.g., missing semicolon, undefined variables). This can also be called syntax erroring.
Fix: Correct the syntax as indicated by the compiler's error messages. -
Runtime Error
When: During program execution.
What: Code crashes due to invalid operations (e.g., division by zero, file not found).
Fix: Debug and handle exceptions or invalid inputs. -
Logic Error
When: Code runs successfully but produces incorrect results.
What: Algorithm or logic flaw (e.g., wrong formula, incorrect loop condition).
Fix: Analyze and revise the code logic to meet the desired outcome.
How does Activerse handle errors?
Activerse uses its custom error handling protocol to report what's happening. This is more efficient than classic Java stack traces because it can help localize errors and prevent the code from crashing on a simple error. This error protocol is known as ACEHS.
ACEHS: Activerse Concurrent Error Handling System
The ultimate goal of ACEHS is:
- To catch identified or unidentified exceptions
- To report those exceptions while the session is still active
- To allow buildups of the ACEHS implementation
Denotations
File name extensions (A: Engine, B: Utils):
- 1A - Activerse.java
- 2A - ActiverseImage.java
- 3A - ActiverseMouseInfo.java
- 4A - ActiverseSound.java
- 5A - Actor.java
- 6A - CollisionManager.java
- 7A - GameLoop.java
- 8A - KeyBoardInfo.java
- 9A - MemoryTracker.java
- 10A - World.java
- 11A - Item.java
- 1B - ActorVector.java
- 2B - FileUtils.java
- 3B - PerlinNoise.java
- 4B - Physics.java
- 5B - Timer.java
- 6B - WorldGeneration.java
- PROP.IN.OUT.IO - Activerse.properties error
Keywords that may be helpful:
- IO - A central breakdown; typically a result of multiple errors caught by ACEHS that cause an IO error
- IN - An input breakdown
- OUT - An output breakdown
- LN - Error line reporting
- DEV - Contact Dev's; this is not a good error
- CONNTO - A connecting line of code that connects class to class and may cause errors in each
Example Error
Let's take an error (without the provided stack trace) and debug it:
5A.OUT-CONNTO-2A.OUT:(LN: paint(Graphics g) - ACEHS Error thrown; image is null. Please check the image path and try again.
This error comes from the Actor.java
engine class inside the paint()
method. The most
important part is seeing the error message before anything else. ACEHS is reporting the image has been
identified as null (blank, unpresent, etc) and is asking us to check the image path once again. Make sure you
check the image paths and use reference paths as well.
5A.OUT shows the error is coming from the class 5A (Actor), but this error may correlate with
the class (CONNTO) 2A (ActiverseImage.java). If you've already debugged via the method above,
the next thing is to check these files and debug properly. LN: points to the method (paint()
)
where the error was reported.
Final Notes
ACEHS helps you quickly identify and resolve errors in Activerse projects. Always read the error message, check the referenced files and methods, and use the denotations to trace the source of the problem.