Robot code runs in a hard real-time loop where an unhandled exception can crash the entire program mid-match. Spectrum follows a set of exception handling conventions that keep errors visible and recoverable without hiding bugs behind silent failures.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/spectrum3847/2026-Spectrum/llms.txt
Use this file to discover all available pages before exploring further.
Core rules
Never use empty catch clauses
Never use empty catch clauses
An empty
catch block swallows exceptions silently, making bugs nearly impossible to debug. At minimum, log the exception or print its stack trace.Bad — hides errors completely
Good — always log the exception
Catch specific exceptions, not generic ones
Catch specific exceptions, not generic ones
Catching
Exception or Throwable generically can suppress critical runtime errors like NullPointerException or ClassCastException that should terminate or be handled specifically.Avoid generic catch
Prefer specific exceptions
Guard against null and array bounds before access
Guard against null and array bounds before access
NullPointerException and ArrayIndexOutOfBoundsException are the most common robot-crashing exceptions. Prevent them with conditional checks before accessing values.java
Use try-catch for unpredictable hardware operations
Use try-catch for unpredictable hardware operations
Network communication, sensor reads, and CAN bus operations can fail unpredictably. Wrap these with
try-catch and fall back to a safe default value.java
Custom exception classes
SpectrumLib’sutil/exceptions/ package provides custom exception types for robot-specific error conditions. Use these instead of generic exceptions when throwing from library code so callers can catch them specifically.
java
The isAttached pattern
Mechanism hardware errors are often pre-empted entirely by theisAttached() guard in Mechanism.java. If a mechanism is not attached (i.e., the hardware is not present on this robot configuration), all control calls are no-ops and sensor reads return safe defaults — no exception needed.
java
