From 92143b9154a445ad9174ea10db78ab4d0c7d29ba Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Thu, 22 Apr 2021 16:34:03 +0200 Subject: [PATCH] [New] ServiceResult.toJson() also checks if ex has I18n --- .../src/main/java/li/strolch/service/api/ServiceResult.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java b/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java index 478b5e221..1f0ff9eba 100644 --- a/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java +++ b/li.strolch.agent/src/main/java/li/strolch/service/api/ServiceResult.java @@ -22,6 +22,7 @@ import static li.strolch.utils.helper.StringHelper.isEmpty; import java.util.ResourceBundle; import com.google.gson.JsonObject; +import li.strolch.exception.StrolchException; import li.strolch.model.i18n.I18nMessageToJsonVisitor; import li.strolch.utils.I18nMessage; @@ -200,9 +201,12 @@ public class ServiceResult { if (this.throwable != null) { json.addProperty("exceptionMsg", getExceptionMessageWithCauses(this.throwable, false)); json.addProperty("throwable", formatException(this.throwable)); + + if (this.throwable instanceof StrolchException && ((StrolchException) this.throwable).hasI18n()) + json.add("i18n", ((StrolchException) this.throwable).getI18n().accept(new I18nMessageToJsonVisitor())); } - if (this.i18nMessage != null) + if (!json.has("i18n") && this.i18nMessage != null) json.add("i18n", this.i18nMessage.accept(new I18nMessageToJsonVisitor())); return json;