From 7fb081d9a43af58dd8ea1de6dac8a36f2063712d Mon Sep 17 00:00:00 2001 From: serso Date: Sun, 22 May 2016 23:12:02 +0200 Subject: [PATCH] Don't send function names in user reports --- .../android/calculator/AcraErrorReporter.java | 8 ++++++++ .../jscl/CustomFunctionCalculationException.java | 13 +++++++++++-- .../src/main/java/jscl/JsclArithmeticException.java | 6 +++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/org/solovyev/android/calculator/AcraErrorReporter.java b/app/src/main/java/org/solovyev/android/calculator/AcraErrorReporter.java index 68b9e103..a845effd 100644 --- a/app/src/main/java/org/solovyev/android/calculator/AcraErrorReporter.java +++ b/app/src/main/java/org/solovyev/android/calculator/AcraErrorReporter.java @@ -23,7 +23,11 @@ package org.solovyev.android.calculator; import android.util.Log; +import jscl.CustomFunctionCalculationException; +import jscl.text.msg.JsclMessage; +import jscl.text.msg.Messages; import org.acra.ACRA; +import org.solovyev.common.msg.MessageType; import javax.annotation.Nonnull; @@ -37,6 +41,10 @@ public class AcraErrorReporter implements ErrorReporter { Log.e("Acra", e.getMessage(), e); return; } + if (e instanceof CustomFunctionCalculationException) { + final CustomFunctionCalculationException e1 = (CustomFunctionCalculationException) e; + e1.setMessage(new JsclMessage(Messages.msg_19, MessageType.error, "XXX", e1.getCauseMessage().getMessageCode())); + } ACRA.getErrorReporter().reportBuilder().forceSilent().exception(e).send(); } diff --git a/jscl/src/main/java/jscl/CustomFunctionCalculationException.java b/jscl/src/main/java/jscl/CustomFunctionCalculationException.java index 43a880e3..35500eeb 100644 --- a/jscl/src/main/java/jscl/CustomFunctionCalculationException.java +++ b/jscl/src/main/java/jscl/CustomFunctionCalculationException.java @@ -8,7 +8,16 @@ import javax.annotation.Nonnull; public class CustomFunctionCalculationException extends JsclArithmeticException { - public CustomFunctionCalculationException(@Nonnull CustomFunction function, @Nonnull Message message) { - super(Messages.msg_19, function.getName(), message); + @Nonnull + private final Message causeMessage; + + public CustomFunctionCalculationException(@Nonnull CustomFunction function, @Nonnull Message causeMessage) { + super(Messages.msg_19, function.getName(), causeMessage); + this.causeMessage = causeMessage; + } + + @Nonnull + public Message getCauseMessage() { + return causeMessage; } } diff --git a/jscl/src/main/java/jscl/JsclArithmeticException.java b/jscl/src/main/java/jscl/JsclArithmeticException.java index ace9f966..97c06f1a 100644 --- a/jscl/src/main/java/jscl/JsclArithmeticException.java +++ b/jscl/src/main/java/jscl/JsclArithmeticException.java @@ -12,7 +12,7 @@ import java.util.Locale; public abstract class JsclArithmeticException extends ArithmeticException implements Message { @Nonnull - private final Message message; + private Message message; public JsclArithmeticException(@Nonnull String messageCode, Object... parameters) { this.message = new JsclMessage(messageCode, MessageType.error, parameters); @@ -58,4 +58,8 @@ public abstract class JsclArithmeticException extends ArithmeticException implem public int hashCode() { return message.hashCode(); } + + public void setMessage(@Nonnull Message message) { + this.message = message; + } }