Last active
May 17, 2020 20:50
-
-
Save psygo/58783a6caa08e89b5df3f1553c08e7fa to your computer and use it in GitHub Desktop.
An exception template which you can extend (inheritance... since `Exceptions` typically have the same implementations)
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
import 'package:meta/meta.dart'; | |
// import 'package:flutter/foundation.dart'; // Alternative for Flutter | |
@immutable | |
abstract class CustomizableException implements Exception { | |
static const String blankMsg = ''; | |
static const String divider = ': '; | |
final String msg; | |
const CustomizableException([msg]): msg = msg ?? blankMsg; | |
@override | |
String toString() => '$runtimeType$divider$msg'; | |
} | |
@immutable | |
class CustomException extends CustomizableException { | |
const CustomException([msg]): super(msg); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment