feat(shorebird_code_push): override toString in exceptions (#266)

Co-authored-by: Felix Angelov <felix@shorebird.dev>
This commit is contained in:
0xcf2f
2025-02-07 22:47:56 +01:00
committed by GitHub
parent 78c84e5bf7
commit 38efba0e6a
2 changed files with 33 additions and 0 deletions
@@ -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'),
);
});
});
});
}