Null, exceptions and stack traces
Why programs crash, how to read the error, and how to stop it happening.
This page is still being written.
What it will cover
- null: a variable that points at nothing; NullPointerException with a runnable example (expectExit 1) and its helpful message
- Null checks, early returns, @Nullable in the Paper API (Bukkit.getPlayerExact returns null when offline)
- Exceptions: try/catch/finally, throw, checked vs unchecked, multi-catch, try-with-resources
- Reading a stack trace top to bottom; Caused by; finding your own class and line number (annotated x-console)
- Common exceptions table: NullPointerException, NumberFormatException, ArrayIndexOutOfBounds, ClassCastException, IllegalArgumentException, IllegalStateException, ConcurrentModificationException
- Validating player input (Integer.parseInt with catch)
- Link to Error Doctor and debugging chapter