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

Side by Side Diff: runtime/lib/arrays.dart

Issue 10786045: Improve the error messages for IndexOutOfRangeException. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « corelib/src/exceptions.dart ('k') | runtime/lib/byte_array.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 // TODO(ngeoffray): Rename to Lists. 5 // TODO(ngeoffray): Rename to Lists.
6 class Arrays { 6 class Arrays {
7 static void copy(List src, int srcStart, 7 static void copy(List src, int srcStart,
8 List dst, int dstStart, int count) { 8 List dst, int dstStart, int count) {
9 if (srcStart === null) srcStart = 0; 9 if (srcStart === null) srcStart = 0;
10 if (dstStart === null) dstStart = 0; 10 if (dstStart === null) dstStart = 0;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 74 }
75 } 75 }
76 return -1; 76 return -1;
77 } 77 }
78 78
79 static void rangeCheck(List a, int start, int length) { 79 static void rangeCheck(List a, int start, int length) {
80 if (length < 0) { 80 if (length < 0) {
81 throw new IllegalArgumentException("negative length $length"); 81 throw new IllegalArgumentException("negative length $length");
82 } 82 }
83 if (start < 0 || start >= a.length) { 83 if (start < 0 || start >= a.length) {
84 throw new IndexOutOfRangeException(start); 84 String message = "$start must be in the range [0..${a.length})";
85 throw new IndexOutOfRangeException(message);
85 } 86 }
86 if (start + length > a.length) { 87 if (start + length > a.length) {
87 throw new IndexOutOfRangeException(start + length); 88 String message = "$start + $length must be in the range [0..${a.length})";
89 throw new IndexOutOfRangeException(message);
88 } 90 }
89 } 91 }
90 } 92 }
91 93
OLDNEW
« no previous file with comments | « corelib/src/exceptions.dart ('k') | runtime/lib/byte_array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698