Exception Handling

 /// Exception Handling : The execution of the program is terminated abnormally

/// DifferedLoadException : Thrown when a deferred library fails to load
/// FromatException : The exception is thrown when a string or some other data does not have an expected format
/// and can't be processed
/// IntegerDivisionByZeroException : The exception is thrown when a number is divided by zero
/// IOException : Base class for all Input-Output related exceptions
/// IsolateSpawnException : Thrown when an isolate can not be created
/// OSError : An Exception holding information about an error from the operating system
/// TimeoutException : Thrown when a scheduled timeout happens while waiting for an async result

//void main() {
// try {
// int x = 5 ~/ 0;
// print(x);
// } on IntegerDivisionByZeroException {
// print("Can not divide by zero");
// };

/// catch clause :
/// when we don't know about the exception then use the catch clause
/// We can spacify one or two parameters to catch(). The first is the "exception object" that was thrown,
/// and the second is the "StackTrace object".
// try {
// int x = 5 ~/ 0;
// print("$x");
// }
// catch(e) { // Here, "e" is exception object
// print("Exception : $e");
// }

// try {
// int y = 5 ~/ 0;
// print("$y");
// }
// //Here, "e" is exception object, "s" is StackTrace object
// catch(e, s) {
// print("Exception : $e");
// print(s);
// }

/// Finally clause : To ensure that some code runs whether or not an exception is thrown, use a finally clause
/// To ensure the execution of program, finally clause is used
// try {
// int z = 5 ~/ 0;
// print("$z");
// } catch(e) {
// //print("Exception : $e");
// } finally {
// print("finally clause...");
// }

//}

Comments

Popular posts from this blog

Second GET API Calling with Bloc simple Example in Flutter

Stack Container Scrollable Card widget UI with Custom Widget

Pagination with Bloc Pattern in Flutter