77import "package:collection/collection.dart" ;
88import "package:curie/curie.dart" ;
99
10+ import "../../exceptions.dart" ;
1011import "../additional_expected_response.dart" ;
1112import "../data_schema.dart" ;
1213import "../expected_response.dart" ;
@@ -26,7 +27,6 @@ import "../security/oauth2_security_scheme.dart";
2627import "../security/psk_security_scheme.dart" ;
2728import "../security/security_scheme.dart" ;
2829import "../thing_description.dart" ;
29- import "../validation/validation_exception.dart" ;
3030import "../version_info.dart" ;
3131
3232const _validTdContextValues = [
@@ -638,7 +638,9 @@ List<ContextEntry> _parseContext(
638638 final value = entry.value;
639639
640640 if (value is ! String ) {
641- throw ContextValidationException (value.runtimeType);
641+ throw ValidationException (
642+ "Excepted either a String or a Map<String, String> "
643+ "as @context entry, got ${value .runtimeType } instead." );
642644 }
643645
644646 if (! key.startsWith ("@" ) && Uri .tryParse (value) != null ) {
@@ -649,16 +651,6 @@ List<ContextEntry> _parseContext(
649651 }
650652 }
651653
652- throw ContextValidationException (json.runtimeType);
653- }
654-
655- /// Custom [ValidationException] that is thrown for an invalid [ContextEntry] .
656- class ContextValidationException extends ValidationException {
657- /// Creates a new [ContextValidationException] indicating the invalid
658- /// [runtimeType] .
659- ContextValidationException (Type runtimeType)
660- : super (
661- "Excepted either a String or a Map<String, String> "
662- "as @context entry, got $runtimeType instead." ,
663- );
654+ throw ValidationException ("Excepted either a String or a Map<String, String> "
655+ "as @context entry, got ${json .runtimeType } instead." );
664656}
0 commit comments