Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Catch exception

  • try
  • catch
div(x, y) {
  return x ~/ y;
}

main()  {
  try {
    print(div(2, 1));
    print(div(1, 0));
    print(div(3, 1));
  } catch(exception, stackTrace) {
    print(exception);
    print(stackTrace);
  }
  print("still working");
}

{% embed include file="src/examples/dart-intro/catch_exception.out)