Dart Exceptions
try, catch and finally handle errors. on catches a specific type and throw raises one. Throw Error for bugs and Exception for recoverable problems.
Example
void main() {
try {
int.parse("abc");
} on FormatException catch (e) {
print("Bad number");
} finally {
print("done");
}
}Exercise
Catch a specific type.
FormatException catch (e)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.