summaryrefslogtreecommitdiff
path: root/player-android/lib/utils/error_mappers.dart
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-21 18:47:51 +0300
committerPaul Buetow <paul@buetow.org>2026-05-21 18:47:51 +0300
commitd9887828685db241e01436e99885056eb61f06c1 (patch)
tree445772f1f901ada768ed7d9c18312d7de02a1b33 /player-android/lib/utils/error_mappers.dart
parente58a12ee773da39d639ebb0e26fdb1b782941c56 (diff)
Implement Tag picker with optimistic UI, autocomplete, and delete chips on MediaDetailScreen (5b)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'player-android/lib/utils/error_mappers.dart')
-rw-r--r--player-android/lib/utils/error_mappers.dart22
1 files changed, 22 insertions, 0 deletions
diff --git a/player-android/lib/utils/error_mappers.dart b/player-android/lib/utils/error_mappers.dart
index 2d6f446..ea20412 100644
--- a/player-android/lib/utils/error_mappers.dart
+++ b/player-android/lib/utils/error_mappers.dart
@@ -158,6 +158,28 @@ String continueWatchingErrorMessage(Object error) {
return 'Unexpected error. Please try again.';
}
+/// Maps any thrown object from [PlayerApiClient.addTag] or
+/// [PlayerApiClient.removeTag] to a UI string.
+///
+/// Adds human-readable messages for the common failure modes:
+/// - 400: the tag name is invalid (empty, too long, etc.).
+/// - 404: the media item no longer exists.
+///
+/// Kept as a separate top-level function (Open-Closed, DRY) so it can evolve
+/// independently of the other mappers without touching unrelated screens.
+String tagErrorMessage(Object error) {
+ if (error is DioException) {
+ if (error.response?.statusCode == 404) {
+ return 'Media not found. It may have been deleted.';
+ }
+ if (error.response?.statusCode == 400) {
+ return 'Invalid tag name. Please try a different tag.';
+ }
+ return dioConnectionErrorMessage(error);
+ }
+ return 'Unexpected error. Please try again.';
+}
+
/// Maps any thrown object from [PlayerApiClient.subscribePodcast] to a UI string.
///
/// Adds human-readable messages for the common failure modes: