[New] ServiceResult.toJson() also checks if ex has I18n
This commit is contained in:
parent
523d1372c1
commit
92143b9154
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue