Dart Chapter 9 of 15
Error Handling
Deal with things going wrong: catch exceptions with try and catch, clean up with finally, and define your own exception types.
Files go missing, networks drop and users type nonsense. A program that handles these situations keeps running and tells the user what happened. One that does not simply crashes.
Lessons in this chapter
- Exception Handling in Dart: try, catch, on and finallyLearn exception handling in Dart: throw, try, catch, on, finally and rethrow, the difference between Exception and Error, and best practices.
- Custom Exceptions in DartCreate your own exception classes in Dart by implementing Exception. Add fields, build exception hierarchies and handle them with on.