Last active
February 25, 2021 16:27
-
-
Save guid-empty/795d7fcb3773fbf2f1f4e07423e13f17 to your computer and use it in GitHub Desktop.
Dart.Language.Exceptions handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
/// Error - это фейл, который мы никак не предусматривали. | |
/// В таких случаях приложение умирает. | |
/// Exception - это то, что мы закладываем в логике | |
/// работы нашего приложения. | |
/// | |
void main() { | |
try { | |
int products; | |
int backets = 7; | |
stackOverflowMethod(); | |
print(products * backets); | |
} on NoSuchMethodError { | |
print('Случилось страшное!!!'); | |
} on OutOfMemoryError { | |
print('А это полный треш!!'); | |
} on StackOverflowError catch (e) { | |
print('StackOverflowError -> Да и это не легче !!'); | |
} catch (e) { | |
print('Произошла ошибка ${e.toString()}'); | |
} finally { | |
print('Но мы справились!!'); | |
} | |
} | |
void stackOverflowMethod() { | |
stackOverflowMethod(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment