Skip to content

Commit

Permalink
fix: add missing toString() overrides to Exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
JKRhb committed Jun 12, 2022
1 parent 1e90037 commit 582fa23
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 7 deletions.
5 changes: 5 additions & 0 deletions lib/src/core/consumed_thing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ class UnexpectedReponseException implements Exception {

/// Creates a new [UnexpectedReponseException] from an error [message].
UnexpectedReponseException(this.message);

@override
String toString() {
return message;
}
}

/// Implementation of the [scripting_api.ConsumedThing] interface.
Expand Down
5 changes: 5 additions & 0 deletions lib/src/core/content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ class ContentDeserializationException implements Exception {

/// Creates a new [ContentDeserializationException] with an error [message].
ContentDeserializationException(this.message, this.error);

@override
String toString() {
return "$runtimeType: $message";
}
}

void _onError(Object error) {
Expand Down
5 changes: 5 additions & 0 deletions lib/src/core/content_serdes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class ContentSerdesException implements Exception {

/// Constructor.
ContentSerdesException(this.message);

@override
String toString() {
return "$runtimeType: $message";
}
}

/// Class providing serializing and deserializing capabilities.
Expand Down
16 changes: 9 additions & 7 deletions lib/src/core/wot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ import 'thing_discovery.dart' show ThingDiscovery;
/// This [Exception] is thrown if an error during the consumption of a
/// [ThingDescription] occurs.
class ThingConsumptionException implements Exception {
/// The actual error message.
String message;

/// The identifier of the [ThingDescription] that triggered this [Exception].
String identifier;
final String identifier;

/// Constructor
ThingConsumptionException(this.message, this.identifier);
ThingConsumptionException(this.identifier);

@override
String toString() {
return "$runtimeType: A ConsumedThing with identifier $identifier already "
"exists.";
}
}

/// Implementation of the [scripting_api.WoT] runtime interface.
Expand All @@ -45,8 +48,7 @@ class WoT implements scripting_api.WoT {
return newThing;
} else {
final id = thingDescription.identifier;
throw ThingConsumptionException(
"A ConsumedThing with identifier $id already exists", id);
throw ThingConsumptionException(id);
}
}

Expand Down
5 changes: 5 additions & 0 deletions lib/src/definitions/form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,9 @@ class UriVariableException implements Exception {

/// Constructor.
UriVariableException(this.message);

@override
String toString() {
return "$runtimeType: $message";
}
}

0 comments on commit 582fa23

Please sign in to comment.