fix with logger + jscl version update

This commit is contained in:
Sergey Solovyev
2013-01-15 21:54:25 +04:00
parent 1e2b5ac830
commit bfe89e893d
8 changed files with 32 additions and 28 deletions

View File

@@ -6,12 +6,12 @@
package org.solovyev.android.calculator;
import jscl.CustomFunctionCalculationException;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.solovyev.common.JBuilder;
import org.solovyev.common.math.MathEntity;
import org.solovyev.common.math.MathRegistry;
import org.solovyev.common.msg.Message;
import java.util.List;
import java.util.Map;
@@ -68,9 +68,13 @@ public abstract class AbstractCalculatorMathRegistry<T extends MathEntity, P ext
for (P entity : persistenceContainer.getEntities()) {
if (!contains(entity.getName())) {
try {
add(createBuilder(entity));
} catch (CustomFunctionCalculationException e) {
Locator.getInstance().getLogger().error(null, e.getMessage(), e);
final JBuilder<? extends T> builder = createBuilder(entity);
add(builder);
} catch (ArithmeticException e) {
Locator.getInstance().getLogger().error(null, e.getLocalizedMessage(), e);
if (e instanceof Message) {
Locator.getInstance().getNotifier().showMessage((Message)e);
}
}
}
}

View File

@@ -12,8 +12,8 @@ public interface CalculatorLogger {
void debug(@Nullable String tag, @NotNull String message);
void debug(@Nullable String tag, @NotNull String message, @NotNull Throwable e);
void debug(@Nullable String tag, @Nullable String message, @NotNull Throwable e);
void error(@Nullable String tag, @NotNull String message, @NotNull Throwable e);
void error(@Nullable String tag, @Nullable String message, @NotNull Throwable e);
}

View File

@@ -79,7 +79,7 @@ public class CalculatorParseException extends SersoException implements Message
}
@Override
@Nullable
@NotNull
public String getLocalizedMessage() {
return this.message.getLocalizedMessage(Locale.getDefault());
}

View File

@@ -14,7 +14,7 @@ public class SystemOutCalculatorLogger implements CalculatorLogger {
private static final String TAG = SystemOutCalculatorLogger.class.getSimpleName();
@Override
public void debug(@Nullable String tag, @NotNull String message) {
public void debug(@Nullable String tag, @Nullable String message) {
System.out.println(getTag(tag) + ": " + message);
}
@@ -24,13 +24,13 @@ public class SystemOutCalculatorLogger implements CalculatorLogger {
}
@Override
public void debug(@Nullable String tag, @NotNull String message, @NotNull Throwable e) {
public void debug(@Nullable String tag, @Nullable String message, @NotNull Throwable e) {
debug(tag, message);
e.printStackTrace(System.out);
}
@Override
public void error(@Nullable String tag, @NotNull String message, @NotNull Throwable e) {
public void error(@Nullable String tag, @Nullable String message, @NotNull Throwable e) {
System.out.println(getTag(tag) + ": " + message);
e.printStackTrace(System.out);
}

View File

@@ -308,7 +308,7 @@ public class AFunction implements IFunction, MathPersistenceEntity, Serializable
}
@Override
@Nullable
@NotNull
public String getLocalizedMessage() {
return message.getLocalizedMessage();
}