Dart Exception : Finally Clause
Jeet Bhalu
1 min read
Finally clause :
To ensure that some code runs whether or not an exception is thrown, use a
finally
clause. If nocatch
clause matches the exception, the exception is propagated after thefinally
clause runs:try { breedMoreLlamas(); } finally { // Always clean up, even if an exception is thrown. cleanLlamaStalls(); }
The
finally
clause runs after any matchingcatch
clauses:try { breedMoreLlamas(); } catch (e) { print('Error: $e'); // Handle the exception first. } finally { cleanLlamaStalls(); // Then clean up. }
0
Subscribe to my newsletter
Read articles from Jeet Bhalu directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Dart#dart language#dart-for-beginnersdart programming tutorial#dart-keywordsDevops#DevopscommunityDevOps JourneyDeveloperDevops articlesdevelopmentdevOpen SourceObject Oriented ProgrammingProgramming Blogs
Written by
Jeet Bhalu
Jeet Bhalu
i am Jeet Bhalu i am flutter App developer