Commit 19e93c98 authored by Hans Boehm's avatar Hans Boehm
Browse files

Reflect conversion of CR to unchecked exceptions

Bug: 20667245

Update calculator code to reflect the fact that CR Errors have
become exceptions, and they are now delcared local to CR.

Change-Id: Ie9c9e10cef2f98a23856aa9e49328ae7ba52c9bc
parent 79ffb522
......@@ -29,7 +29,6 @@ package com.android.calculator2;
import java.math.BigInteger;
import com.hp.creals.CR;
import com.hp.creals.AbortedError;
public class BoundedRational {
// TODO: Maybe eventually make this extend Number?
......@@ -386,7 +385,7 @@ public class BoundedRational {
}
BoundedRational tmp = pow(exp.shiftRight(1));
if (Thread.interrupted()) {
throw new AbortedError();
throw new CR.AbortedException();
}
return multiply(tmp, tmp);
}
......@@ -453,11 +452,11 @@ public class BoundedRational {
if (n > 4 * step) {
BigInteger prod1 = genFactorial(n, 2 * step);
if (Thread.interrupted()) {
throw new AbortedError();
throw new CR.AbortedException();
}
BigInteger prod2 = genFactorial(n - step, 2 * step);
if (Thread.interrupted()) {
throw new AbortedError();
throw new CR.AbortedException();
}
return prod1.multiply(prod2);
} else {
......
......@@ -88,9 +88,7 @@ import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;
import com.hp.creals.AbortedError;
import com.hp.creals.CR;
import com.hp.creals.PrecisionOverflowError;
import java.io.DataInput;
import java.io.DataOutput;
......@@ -233,9 +231,9 @@ class Evaluator {
return new ReevalResult(mVal.toString(eval_prec), eval_prec);
} catch(ArithmeticException e) {
return null;
} catch(PrecisionOverflowError e) {
} catch(CR.PrecisionOverflowException e) {
return null;
} catch(AbortedError e) {
} catch(CR.AbortedException e) {
// Should only happen if the task was cancelled,
// in which case we don't look at the result.
return null;
......@@ -252,7 +250,7 @@ class Evaluator {
mCalculator.onError(R.string.error_nan);
} else {
if (result.mNewCacheDigs < mCacheDigs) {
throw new Error("Unexpected onPostExecute timing");
throw new AssertionError("Unexpected onPostExecute timing");
}
mCache = result.mNewCache;
mCacheDigs = result.mNewCacheDigs;
......@@ -411,11 +409,11 @@ class Evaluator {
return new InitialResult(R.string.error_zero_divide);
} catch(ArithmeticException e) {
return new InitialResult(R.string.error_nan);
} catch(PrecisionOverflowError e) {
} catch(CR.PrecisionOverflowException e) {
// Extremely unlikely unless we're actually dividing by
// zero or the like.
return new InitialResult(R.string.error_overflow);
} catch(AbortedError e) {
} catch(CR.AbortedException e) {
return new InitialResult(R.string.error_aborted);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment