Skip to content

Commit

Permalink
fix(consumed_thing): don't catch all subscribe exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Feb 19, 2022
1 parent 6893e03 commit d5c2226
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions lib/src/core/consumed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,23 +277,17 @@ class ConsumedThing implements scripting_api.ConsumedThing {
final form = clientAndForm.form; // TODO(JKRhb): Handle URI variables
final client = clientAndForm.client;

final subscription = await client.subscribeResource(form,
next: (content) {
try {
listener(InteractionOutput(
content, servient.contentSerdes, form, dataSchema));
} on Exception {
// Exception is handled by onError function. Not sure if this is the
// best design, though.
// TODO(JKRhb): Check if this try-catch-block can be removed.
}
},
error: (error) {
if (onError != null) {
onError(error);
}
},
complete: () => removeSubscription(affordanceName, subscriptionType));
final subscription = await client.subscribeResource(
form,
next: (content) => listener(
InteractionOutput(content, servient.contentSerdes, form, dataSchema)),
error: (error) {
if (onError != null) {
onError(error);
}
},
complete: () => removeSubscription(affordanceName, subscriptionType),
);
if (subscriptionType == SubscriptionType.property) {
_observedProperties[affordanceName] = subscription;
} else {
Expand Down

0 comments on commit d5c2226

Please sign in to comment.