Tsallaka zuwa abun ciki
Justice Tech School

try, catch and finally

Handle exceptions with on and catch. finally always runs.

Example
try {
  int.parse("abc");
} on FormatException catch (e) {
  print("bad number");
} finally {
  print("done");
}

Exercise

Always runs.

try {}  {}

Quiz Test

What does on do?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.