From d261640fa7cd2b28cfa40ec53267388d2ab4e5d7 Mon Sep 17 00:00:00 2001 From: Austin Adams Date: Tue, 26 Sep 2023 18:28:20 -0400 Subject: [PATCH] Throw a slightly more friendly message when a student opens an empty file This error gets propagated to autograders, so a more friendly error message is useful --- src/main/java/com/ra4king/circuitsim/gui/CircuitSim.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/com/ra4king/circuitsim/gui/CircuitSim.java b/src/main/java/com/ra4king/circuitsim/gui/CircuitSim.java index d3bf221..cb0802f 100644 --- a/src/main/java/com/ra4king/circuitsim/gui/CircuitSim.java +++ b/src/main/java/com/ra4king/circuitsim/gui/CircuitSim.java @@ -1474,6 +1474,9 @@ public void loadCircuits(File file) throws Exception { CircuitFile circuitFile = FileFormat.load(lastSaveFile); + if (circuitFile == null) { + throw new NullPointerException("File is empty!"); + } if (circuitFile.circuits == null) { throw new NullPointerException("File missing circuits"); }