exception_templates library
Provides generic exception and error templates.
Enables throwing specific errors/exceptions without having to declare new classes.
Classes
- ErrorType
- Base class for creating new error types.
- ExceptionType
- Base class for creating new exception types.
- InvalidIdentifier
- ErrorType indicating that an invalid Dart identifier was detected.
Enums
- AnsiColor
- Represents and Ansi colour.
- ColorOutput
Constants
-
reservedWords
→ const Set<
String>
Functions
-
classNameToLibraryName(
String className) → String - Converts a capital camel case Dart class name to a lower case underscore separated Dart library name.
-
isValidIdentifier(
String input) → bool -
Returns
true
ifinput
is a valid Dart variable identifier. -
toColorString(
{Object message = '', Object expectedState = '', Object invalidState = '', ColorOutput colorOutput = ColorOutput.on, required Type errorType}) → String - Transforms error/exception messages to a colorized output string.
-
validateIdentifier(
String input) → void -
Throws an
ErrorOfType<InvalidIdentifier>
ifinput
is not a valid Dart identifier.
Exceptions / Errors
-
ErrorOf<
T> - Parameterized error template.
-
ErrorOfType<
T extends ErrorType> - Parameterized error template.
-
ExceptionOf<
T> - Parameterized exception class. The type argument indicates in which context the exception occured.
-
ExceptionOfType<
T extends ExceptionType> -
Parameterized exception template.
The generic type
T
indicates what type of error occured. Usage: