From 2ec999f12eba4b8587855f2d3382370d8d1a9d70 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Wed, 12 Aug 2026 17:50:39 +0200 Subject: [PATCH] Throw dedicated exception instead of `RuntimeException` --- .../main/java/run/endive/compiler/internal/TypeStack.java | 5 +++-- .../src/main/java/run/endive/runtime/InterpreterMachine.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler/src/main/java/run/endive/compiler/internal/TypeStack.java b/compiler/src/main/java/run/endive/compiler/internal/TypeStack.java index f5fc264bd..bd977ae85 100644 --- a/compiler/src/main/java/run/endive/compiler/internal/TypeStack.java +++ b/compiler/src/main/java/run/endive/compiler/internal/TypeStack.java @@ -6,6 +6,7 @@ import java.util.Deque; import java.util.HashMap; import java.util.Map; +import run.endive.wasm.InvalidException; import run.endive.wasm.types.FunctionType; import run.endive.wasm.types.Instruction; import run.endive.wasm.types.OpCode; @@ -91,10 +92,10 @@ public Deque types() { public void verifyEmpty() { if (types.size() != 1) { - throw new RuntimeException("Bad types stack: " + types); + throw new InvalidException("Bad types stack: " + types); } if (!types().isEmpty()) { - throw new RuntimeException("Types not empty: " + types()); + throw new InvalidException("Types not empty: " + types()); } } } diff --git a/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java b/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java index 6849fa0f5..a6f2e2950 100644 --- a/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java +++ b/runtime/src/main/java/run/endive/runtime/InterpreterMachine.java @@ -58,7 +58,7 @@ protected void evalDefault( Instruction instruction, Operands operands) throws WasmEngineException { - throw new RuntimeException("Machine doesn't recognize Instruction " + instruction); + throw new WasmEngineException("Machine doesn't recognize Instruction " + instruction); } @Override