From df234faa00d4b8ef2e95b8be205083b6c0353138 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 25 Jan 2024 17:25:13 +0100 Subject: [PATCH] Fix RecipeExceptionJS swallowing underlying errors --- .../mods/kubejs/recipe/RecipeExceptionJS.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/dev/latvian/mods/kubejs/recipe/RecipeExceptionJS.java b/common/src/main/java/dev/latvian/mods/kubejs/recipe/RecipeExceptionJS.java index b5b5ad56f..aa09f9bf0 100644 --- a/common/src/main/java/dev/latvian/mods/kubejs/recipe/RecipeExceptionJS.java +++ b/common/src/main/java/dev/latvian/mods/kubejs/recipe/RecipeExceptionJS.java @@ -15,7 +15,19 @@ public RecipeExceptionJS(String m, Throwable cause) { @Override public String toString() { - return getLocalizedMessage(); + var sb = new StringBuilder(); + sb.append(getMessage()); + if (error) { + sb.append(" [error]"); + } + + // append cause as well since RecipeExceptions can swallow underlying problems + if (getCause() != null) { + sb.append("\ncause: "); + sb.append(getCause()); + } + + return sb.toString(); } public RecipeExceptionJS error() {