diff --git a/lib/src/core/implementation/servient.dart b/lib/src/core/implementation/servient.dart index 75435b7b..b8bfcc21 100644 --- a/lib/src/core/implementation/servient.dart +++ b/lib/src/core/implementation/servient.dart @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: BSD-3-Clause +import "dart:developer"; + import "package:meta/meta.dart"; import "package:uuid/uuid.dart"; @@ -379,6 +381,21 @@ class InternalServient implements Servient { return ThingDescription.fromJson(dataSchemaValue.value); } + Stream _processThingDescriptions( + List rawThingDescriptions, + ) async* { + for (final rawThingDescription in rawThingDescriptions) { + if (rawThingDescription is Map) { + try { + yield rawThingDescription.toThingDescription(); + } on Exception catch (e) { + log(e.toString()); + continue; + } + } + } + } + /// Retrieves [ThingDescription] from a Thing Description Directory (TDD). /// /// This method expects the TDD's Thing Description to be located under the @@ -435,9 +452,8 @@ class InternalServient implements Servient { ); } - final thingDescriptionStream = Stream.fromIterable( - rawThingDescriptions.whereType>(), - ).map((rawThingDescription) => rawThingDescription.toThingDescription()); + final thingDescriptionStream = + _processThingDescriptions(rawThingDescriptions); return ThingDiscoveryProcess(thingDescriptionStream, thingFilter); }