Skip to content

Instantly share code, notes, and snippets.

@GitHubStuff
Last active November 8, 2020 16:59
Show Gist options
  • Save GitHubStuff/2d30cb8e6b3a3df38bb01ee8d7c21a7c to your computer and use it in GitHub Desktop.
Save GitHubStuff/2d30cb8e6b3a3df38bb01ee8d7c21a7c to your computer and use it in GitHub Desktop.
Extend Exception for custom error messages
// Create Exception classes by extending this class.
/// - Example:
/*
class UnknownThemeMode extends AppException {
UnknownThemeMode([String message, int code]) : super(message, 'Missing Context', code);
}
*/
class AppException implements Exception {
final message;
final prefix;
final code;
AppException([this.message, this.prefix, this.code]);
String toString() {
return '{"$prefix" : $message", "code":$code}';
}
}
@GitHubStuff
Copy link
Author

Added a some instructions

@GitHubStuff
Copy link
Author

better instruction layout

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment