feat(shorebird_code_push): override toString in exceptions (#266)
Co-authored-by: Felix Angelov <felix@shorebird.dev>
This commit is contained in:
@@ -26,6 +26,9 @@ class ReadPatchException implements Exception {
|
||||
|
||||
/// The human-readable error message.
|
||||
final String message;
|
||||
|
||||
@override
|
||||
String toString() => '[ShorebirdUpdater] ReadPatchException: $message';
|
||||
}
|
||||
|
||||
/// {@template update_exception}
|
||||
@@ -41,6 +44,11 @@ class UpdateException implements Exception {
|
||||
|
||||
/// The reason the update failed.
|
||||
final UpdateFailureReason reason;
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return '[ShorebirdUpdater] UpdateException: $message (${reason.name})';
|
||||
}
|
||||
}
|
||||
|
||||
/// Log message when the Shorebird updater is unavailable in the current
|
||||
|
||||
@@ -11,5 +11,30 @@ void main() {
|
||||
expect(ShorebirdUpdater.new, returnsNormally);
|
||||
}),
|
||||
);
|
||||
|
||||
group(UpdateException, () {
|
||||
test('overrides toString', () {
|
||||
const message = 'message';
|
||||
const reason = UpdateFailureReason.downloadFailed;
|
||||
const exception = UpdateException(message: message, reason: reason);
|
||||
expect(
|
||||
exception.toString(),
|
||||
equals(
|
||||
'[ShorebirdUpdater] UpdateException: $message (${reason.name})',
|
||||
),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group(ReadPatchException, () {
|
||||
test('overrides toString', () {
|
||||
const message = 'message';
|
||||
const exception = ReadPatchException(message: message);
|
||||
expect(
|
||||
exception.toString(),
|
||||
equals('[ShorebirdUpdater] ReadPatchException: $message'),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user