Errors versus exceptions
Runtime faults can and do occur during the execution of a Dart program. We can split all faults into two types:
There is always some confusion on deciding when to use each kind of fault, but you will be given several general rules to make your life a bit easier. All your decisions will be based on the simple principle of recoverability. If your code generates a fault that can reasonably be recovered from, use exceptions. Conversely, if the code generates a fault that cannot be recovered from, or where continuing the execution would do more harm, use errors.
Let's take a look at each of them in detail.
An error occurs if your code has programming errors that should be fixed by the programmer. Let's take ...