summaryrefslogtreecommitdiff
path: root/player-android/lib/utils
diff options
context:
space:
mode:
Diffstat (limited to 'player-android/lib/utils')
-rw-r--r--player-android/lib/utils/error_mappers.dart14
1 files changed, 14 insertions, 0 deletions
diff --git a/player-android/lib/utils/error_mappers.dart b/player-android/lib/utils/error_mappers.dart
index 5a9996a..7353928 100644
--- a/player-android/lib/utils/error_mappers.dart
+++ b/player-android/lib/utils/error_mappers.dart
@@ -77,3 +77,17 @@ String setsErrorMessage(Object error) {
}
return 'Unexpected error. Please try again.';
}
+
+/// Maps any thrown object from [PlayerApiClient.listMedia] to a UI string.
+///
+/// Identical delegation strategy to [setsErrorMessage]: DioExceptions are
+/// mapped by [dioConnectionErrorMessage]; all other exceptions fall back to a
+/// generic message. Having a separate function preserves the option to add
+/// media-specific status-code overrides (e.g. 403 permission errors) later
+/// without altering the sets helper (Open-Closed Principle).
+String mediaErrorMessage(Object error) {
+ if (error is DioException) {
+ return dioConnectionErrorMessage(error);
+ }
+ return 'Unexpected error. Please try again.';
+}