Skip to content

Instantly share code, notes, and snippets.

@guid-empty
Last active February 25, 2021 16:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guid-empty/795d7fcb3773fbf2f1f4e07423e13f17 to your computer and use it in GitHub Desktop.
Save guid-empty/795d7fcb3773fbf2f1f4e07423e13f17 to your computer and use it in GitHub Desktop.
Dart.Language.Exceptions handling
///
/// 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