Skip to main content

New site for Dart news and articles

For the latest Dart news, visit our new blog at  https://medium.com/dartlang .

BREAKING CHANGE: Changing IndexOutOfRangeException to RangeError

The Dart team has changed IndexOutOfRangeException to RangeException. This change is in bleeding_edge and will most likely show up in the next weekly build of Dart Editor.

Lasse Nielsen writes:


Yet another Error in the family: We have changed IndexOutOfRangeException to RangeError. 
RangeError is an Error, and it extends ArgumentError, suggesting that it should only be used when you get an argument that doesn't fit a valid range. If your own internal indices get out of skew with reality, that's a StateError. 
For a limited time, we have included an IndexOutOfRangeException that subclasses RangeError, so if you are currently throwing IndexOutOfRangeException, it'll keep working (or keep failing correctly with an Error, as it might be). It will be removed again, and soon. 
Catching an IndexOutOfRangeException will *not* work with the new RangeErrors thrown by the system.  
Changed in revision 14405.

As always, we invite you to join our Dart mailing list, ask questions on Stack Overflow, or file feature requests on dartbug.com.