diff options
Diffstat (limited to 'player-android/lib/utils')
| -rw-r--r-- | player-android/lib/utils/error_mappers.dart | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/player-android/lib/utils/error_mappers.dart b/player-android/lib/utils/error_mappers.dart index e90b9c2..c1ca5e9 100644 --- a/player-android/lib/utils/error_mappers.dart +++ b/player-android/lib/utils/error_mappers.dart @@ -109,3 +109,23 @@ String mediaDetailErrorMessage(Object error) { } return 'Unexpected error. Please try again.'; } + +/// Maps any thrown object from [PlayerApiClient.createShare] to a UI string. +/// +/// Adds a 404-specific message (media not found) and a 403 message +/// (permission denied) on top of the generic connection-error fallback, so +/// the share dialog can surface actionable guidance rather than a raw code. +/// Kept as a separate function (Open-Closed) so it can evolve independently +/// of the other mappers. +String createShareErrorMessage(Object error) { + if (error is DioException) { + if (error.response?.statusCode == 404) { + return 'Media not found. It may have been deleted.'; + } + if (error.response?.statusCode == 403) { + return 'You do not have permission to share this item.'; + } + return dioConnectionErrorMessage(error); + } + return 'Unexpected error. Please try again.'; +} |
