Line data Source code
1 : /// {@template enum_assist.missing_value_exception} 2 : /// The exception thrown when a value is missing 3 : /// {@endtemplate} 4 : class MissingValueException<T> implements Exception { 5 : /// {@macro enum_assist.missing_value_exception} 6 0 : const MissingValueException(this.key) : assert(key != null); 7 : 8 : /// the key/field of the missing value 9 : final T key; 10 : 11 0 : @override 12 : String toString() { 13 0 : if (key is String) return key as String; 14 : 15 0 : return 'Missing value for: $key'; 16 : } 17 : } 18 : 19 : /// {@template enum_assist.invalid_value_exception} 20 : /// The exception thrown when a value is null 21 : /// and the return type is not nullable 22 : /// {@endtemplate} 23 : class NullValueException implements Exception { 24 : /// {@macro enum_assist.invalid_value_exception} 25 0 : const NullValueException(this.key); 26 : 27 : /// the key/field of the invalid value 28 : final String key; 29 : 30 0 : @override 31 : String toString() { 32 0 : return 'Null value for non-nullable field: $key'; 33 : } 34 : } 35 : 36 : /// {@template enum_assist.missing_extension_value_exception} 37 : /// Thrown when an enum is annotated with an `AdditionalExtension` 38 : /// and the value is missing 39 : /// 40 : /// __only thrown if return type is not nullable__ 41 : /// {@endtemplate} 42 : class MissingExtensionValueException implements Exception { 43 : /// {@macro enum_assist.missing_extension_value_exception} 44 0 : const MissingExtensionValueException(this.key, this.extension); 45 : 46 : /// the key/field of the invalid value 47 : final String key; 48 : 49 : /// the extension that was was expecting a value 50 : final String extension; 51 : 52 0 : @override 53 : String toString() { 54 0 : return '$key is missing a value annotation for $extension'; 55 : } 56 : } 57 : 58 : /// {@template enum_assist.bad_string_format_exception} 59 : /// Thrown when an enum is annotated with an `AdditionalExtension` 60 : /// and the value is missing 61 : /// 62 : /// __only thrown if return type is not nullable__ 63 : /// {@endtemplate} 64 : class BadStringFormatException implements Exception { 65 : /// {@macro enum_assist.bad_string_format_exception} 66 0 : const BadStringFormatException(this.key, this.value); 67 : 68 : /// the key/field of the invalid value 69 : final String key; 70 : 71 : /// the value the was expected to be formatted 72 : final String value; 73 : 74 0 : @override 75 : String toString() { 76 0 : return '$key is not a valid string format: "$value"'; 77 : } 78 : }