Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: runtime/lib/double.dart

Issue 1985823002: Cleanup various argument and range errors in double.dart and integers.dart. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: RangeError.range takes minValue and maxValue of type int, not num. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/double.dart
diff --git a/runtime/lib/double.dart b/runtime/lib/double.dart
index 862aae66ab8114d6c53d5091a587c0a294941684..cbf955dc81a4d791d6cfd36ea6e780aefc2236a7 100644
--- a/runtime/lib/double.dart
+++ b/runtime/lib/double.dart
@@ -117,8 +117,12 @@ class _Double implements double {
double truncateToDouble() native "Double_truncate";
num clamp(num lowerLimit, num upperLimit) {
- if (lowerLimit is! num) throw new ArgumentError(lowerLimit);
- if (upperLimit is! num) throw new ArgumentError(upperLimit);
+ if (lowerLimit is! num) {
+ throw new ArgumentError.value(lowerLimit, "lowerLimit", "not a number");
+ }
+ if (upperLimit is! num) {
+ throw new ArgumentError.value(upperLimit, "upperLimit", "not a number");
+ }
if (lowerLimit.compareTo(upperLimit) > 0) {
throw new ArgumentError(lowerLimit);
@@ -166,11 +170,12 @@ class _Double implements double {
// See ECMAScript-262, 15.7.4.5 for details.
if (fractionDigits is! int) {
- throw new ArgumentError(fractionDigits);
+ throw new ArgumentError.value(
+ fractionDigits, "fractionDigits", "not an integer");
}
// Step 2.
if (fractionDigits < 0 || fractionDigits > 20) {
- throw new RangeError(fractionDigits);
+ throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits");
}
// Step 3.
@@ -200,10 +205,11 @@ class _Double implements double {
// Step 7.
if (fractionDigits != null) {
if (fractionDigits is! int) {
- throw new ArgumentError(fractionDigits);
+ throw new ArgumentError.value(
+ fractionDigits, "fractionDigits", "not an integer");
}
if (fractionDigits < 0 || fractionDigits > 20) {
- throw new RangeError(fractionDigits);
+ throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits");
}
}
@@ -227,11 +233,12 @@ class _Double implements double {
// at the fractionDigits. In Dart we are consistent with toStringAsFixed and
// look at the fractionDigits first.
- if (precision is! int) throw new ArgumentError(precision);
-
+ if (precision is! int) {
+ throw new ArgumentError.value(precision, "precision", "not an integer");
+ }
// Step 8.
if (precision < 1 || precision > 21) {
- throw new RangeError(precision);
+ throw new RangeError.range(precision, 1, 21, "precision");
}
if (isNaN) return "NaN";
« no previous file with comments | « no previous file | runtime/lib/integers.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698