From 2ca92d8425e7af5e1c7c584d9467def4c6ba6c26 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Wed, 17 Dec 2025 23:28:43 +0100 Subject: [PATCH] fix(api): propagate backend error messages to UI instead of showing empty content --- .../iptv/services/xtream_service_mobile.dart | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/features/iptv/services/xtream_service_mobile.dart b/lib/features/iptv/services/xtream_service_mobile.dart index 0d9e121..a8ede25 100644 --- a/lib/features/iptv/services/xtream_service_mobile.dart +++ b/lib/features/iptv/services/xtream_service_mobile.dart @@ -161,6 +161,11 @@ class XtreamServiceMobile { options: _getOptions(), ); + if (response.data is! Map) { + if (response.data is String) + throw Exception('Auth Error: ${response.data}'); + throw Exception('Invalid auth response format'); + } return response.data as Map; } catch (e) { throw Exception('Authentication failed: $e'); @@ -182,7 +187,11 @@ class XtreamServiceMobile { options: _getOptions(), ); - if (response.data is! List) return {}; + if (response.data is! List) { + if (response.data is String) + throw Exception('Category Error: ${response.data}'); + return {}; + } final List categories = response.data as List; final Map categoryMap = {}; @@ -219,7 +228,11 @@ class XtreamServiceMobile { options: _getOptions(), ); - if (response.data is! List) return {}; + if (response.data is! List) { + if (response.data is String) + throw Exception('Live TV Error: ${response.data}'); + return {}; + } final List streams = response.data as List; final Map> groupedChannels = {}; @@ -332,6 +345,8 @@ class XtreamServiceMobile { ); if (response.data is! List) { + if (response.data is String) + throw Exception('VOD Error: ${response.data}'); _cachedMoviesRaw = []; } else { _cachedMoviesRaw = response.data as List; @@ -424,6 +439,8 @@ class XtreamServiceMobile { ); if (response.data is! List) { + if (response.data is String) + throw Exception('Series Error: ${response.data}'); _cachedSeriesRaw = []; } else { _cachedSeriesRaw = response.data as List;