From 0653828fe39771da0a9774e7a0c13d8618ea097e Mon Sep 17 00:00:00 2001 From: MagicBot Date: Sun, 14 Apr 2024 12:13:51 -0400 Subject: [PATCH] Rework of error handling. --- src/engine/gameManager/ForgeManager.java | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/engine/gameManager/ForgeManager.java b/src/engine/gameManager/ForgeManager.java index b941d1f9..f27fdb60 100644 --- a/src/engine/gameManager/ForgeManager.java +++ b/src/engine/gameManager/ForgeManager.java @@ -36,10 +36,20 @@ public enum ForgeManager implements Runnable { while (true) { + WorkOrder workOrder = null; + try { - WorkOrder workOrder = forge.take(); + workOrder = forge.take(); + } catch (InterruptedException e) { + Logger.error(e); + } + + if (workOrder == null) { + Logger.error("NULL workOrder in queue"); + continue; + } - // Completed or canceled work orders are not re-enqueued + // Completed or canceled work orders are not re-enqueued if (workOrder.runCanceled || workOrder.runCompleted) continue; @@ -72,10 +82,6 @@ public enum ForgeManager implements Runnable { workOrder.completionTime = System.currentTimeMillis() + workOrder.rollingDuration; forge.add(workOrder); Logger.info(workOrder.toString()); - - } catch (InterruptedException e) { - e.printStackTrace(); - } } }