Skip to content

Commit

Permalink
fix: replace generic with concrete Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jan 18, 2022
1 parent 9961973 commit 4f1bfb8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions lib/src/core/wot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ class WoT implements scripting_api.WoT {
if (_servient.addThing(newThing)) {
return newThing;
} else {
// TODO(falko17): We should probably use a custom exception type here.
throw Exception('Thing already exists: ${newThing.title}');
throw StateError('Thing already exists: ${newThing.title}');
}
}

Expand Down
3 changes: 1 addition & 2 deletions lib/src/definitions/expected_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ class ExpectedResponse {

static String _parseContentType(dynamic contentType) {
if (contentType is! String) {
// TODO(JKRhb): Define custom exceptions
throw Exception("contentType of response map is not a String!");
throw ArgumentError("contentType of response map is not a String!");
}
return contentType;
}
Expand Down
5 changes: 2 additions & 3 deletions lib/src/scripting_api/subscription.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ Form findUnsubscribeForm(InteractionAffordance interaction,
final unsubscribeForm = _findFormByScoring(interaction, form, operationType);

if (unsubscribeForm == null) {
// TODO(JKRhb): Add appropriate Exception type.
throw Exception("Could not find matching form for unsubscribe");
throw StateError("Could not find matching form for unsubscribe");
}

return unsubscribeForm;
Expand All @@ -68,7 +67,7 @@ String _determineOpType(SubscriptionType? subscriptionType) {
case SubscriptionType.property:
return "unobserveproperty";
default:
throw Exception();
throw ArgumentError();
}
}

Expand Down

0 comments on commit 4f1bfb8

Please sign in to comment.