diff --git a/lib/src/core/interaction_output.dart b/lib/src/core/interaction_output.dart index 5237a7c8..a484cc3b 100644 --- a/lib/src/core/interaction_output.dart +++ b/lib/src/core/interaction_output.dart @@ -52,11 +52,8 @@ class InteractionOutput implements scripting_api.InteractionOutput { return _value.internalValue; } - final schema = this.schema; - if (schema == null) { - // TODO: Throw NotReadableError - throw Exception(); - } + // TODO(JKRhb): Should a NotReadableError be thrown if schema is null? + // C.f. https://w3c.github.io/wot-scripting-api/#the-value-function final value = await _contentSerdes.contentToValue( _content, @@ -64,8 +61,8 @@ class InteractionOutput implements scripting_api.InteractionOutput { ); _dataUsed = true; - _value = (read: true, internalValue: value); - return value; + _value = (read: true, internalValue: value?.value); + return value?.value; } @override diff --git a/lib/src/core/wot.dart b/lib/src/core/wot.dart index 3953be85..4ffa6da1 100644 --- a/lib/src/core/wot.dart +++ b/lib/src/core/wot.dart @@ -117,7 +117,7 @@ class WoT implements scripting_api.WoT { await consumedDirectoryThing.readProperty('things'); final rawThingDescriptions = await interactionOutput.value(); - if (rawThingDescriptions is! scripting_api.DataSchemaValue>) { + if (rawThingDescriptions is! List) { throw DiscoveryException( 'Expected an array of Thing Descriptions but received an ' 'invalid output instead.', @@ -125,7 +125,7 @@ class WoT implements scripting_api.WoT { } final thingDescriptionStream = Stream.fromIterable( - rawThingDescriptions.value.whereType>(), + rawThingDescriptions.whereType>(), ).toThingDescriptionStream(); return ThingDiscoveryProcess(thingDescriptionStream, filter);