Table of Contents
# Built-in Dart exceptions include
DeferredLoadException | Thrown when a deferred library fails to load. |
FormatException | The exception is thrown when a string or some other data does not have an expected format and cannot be parsed or processed. |
IntegerDivisionByZeroException | Thrown when a number is divided by zero. |
IOException | Base class for all Inupt- Output related exceptions. |
IsolateSpawnException | Thrown when an isolate cannot be created. |
Timeout | Thrown when a scheduled timeout happens while waiting for an async result. |
# The try/ on/ catch Blocks
try {
// code that might throw an exception
}
on Exception1 {
// code for handling exception
}
catch Exception2 {
// code for handling exception
}
# The Finally Block
try {
// code that might throw an exception
}
on Exception1 {
// exception handling code
}
catch Exception2 {
// exception handling
}
finally {
// code that should always execute; irrespective of the exception
}
# Throwing an Exception
throw new Exception_name()