dart
Dart Built-in Exceptions and Errors
Exception and Error types thrown by the Dart runtime and core library. Error subtypes represent programming mistakes and should not be caught; Exception subtypes represent runtime conditions that may be handled.
13 codes
· All codes 13 codes
- ArgumentError ArgumentError Thrown when a function or method is called with an invalid argument.
- AssertionError AssertionError Thrown when an assert statement fails. Assertions are only evaluated in debug mode; in production builds they are ignored.
- ConcurrentModificationError ConcurrentModificationError Thrown when a collection is modified while it is being iterated, which would produce unpredictable iteration results.
- FormatException FormatException Thrown when a string or other data cannot be parsed or decoded into the expected format, such as calling int.parse() on a non-numeric string or jsonDecode() on malformed JSON.
- IntegerDivisionByZeroException IntegerDivisionByZeroException Thrown when integer division (~/ or %) is attempted with a divisor of zero.
- NoSuchMethodError NoSuchMethodError Thrown when a method, getter, setter, or operator is invoked on an object that does not have that member. Commonly triggered by calling a method on null in legacy (non-null-safe) code.
- NullThrownError NullThrownError Thrown when null is explicitly thrown with a throw expression. In sound null-safety code this requires a nullable type and is rarely encountered.
- OutOfMemoryError OutOfMemoryError Thrown when the Dart VM cannot allocate enough memory to complete an operation.
- RangeError RangeError A subclass of ArgumentError thrown when a value is outside the valid range, most commonly when accessing a list or string with an out-of-bounds index.
- StackOverflowError StackOverflowError Thrown when the call stack overflows, typically caused by unbounded recursion with no base case.
- StateError StateError Thrown when an object's state makes the requested operation impossible, such as reading from a StreamController after it has been closed or calling Future.value on an already-completed completer.
- TypeError TypeError Thrown when a value does not match an expected type at runtime, such as a failed downcast in sound null-safety code or a type mismatch in dynamic code.
- UnsupportedError UnsupportedError Thrown when an operation is not supported. Commonly thrown by unmodifiable collection views when a mutation method (add, remove, clear) is called.