mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-26 04:49:31 +00:00
debug: add extensive logging and error handling for series
This commit is contained in:
parent
e4a522cc0d
commit
f4d1914b21
2 changed files with 67 additions and 29 deletions
|
|
@ -96,26 +96,40 @@ Future<List<SimpleSeries>> librarySeries(Ref ref) async {
|
|||
return [];
|
||||
}
|
||||
|
||||
// Use raw API call to avoid Series deserialization issues
|
||||
final seriesList = await api.getJson<List<SimpleSeries>>(
|
||||
path: '/api/libraries/${currentLibrary.id}/series',
|
||||
requiresAuth: true,
|
||||
fromJson: (json) {
|
||||
if (json is Map<String, dynamic> && json.containsKey('results')) {
|
||||
final results = json['results'] as List<dynamic>;
|
||||
return results
|
||||
.map((e) => SimpleSeries.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
}
|
||||
return <SimpleSeries>[];
|
||||
},
|
||||
);
|
||||
try {
|
||||
// Use raw API call to avoid Series deserialization issues
|
||||
final seriesList = await api.getJson<List<SimpleSeries>>(
|
||||
path: '/api/libraries/${currentLibrary.id}/series',
|
||||
requiresAuth: true,
|
||||
fromJson: (json) {
|
||||
_logger.info('Series API response: $json');
|
||||
|
||||
if (seriesList == null) {
|
||||
_logger.warning('Failed to fetch series for library ${currentLibrary.id}');
|
||||
return [];
|
||||
if (json is Map<String, dynamic>) {
|
||||
if (json.containsKey('results')) {
|
||||
final results = json['results'] as List<dynamic>;
|
||||
_logger.info('Found ${results.length} series in results');
|
||||
return results
|
||||
.map((e) => SimpleSeries.fromJson(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
} else {
|
||||
_logger.warning('No results key in response. Keys: ${json.keys}');
|
||||
}
|
||||
} else {
|
||||
_logger.warning('Response is not a Map. Type: ${json.runtimeType}');
|
||||
}
|
||||
return <SimpleSeries>[];
|
||||
},
|
||||
);
|
||||
|
||||
if (seriesList == null) {
|
||||
_logger.warning('Failed to fetch series for library ${currentLibrary.id}');
|
||||
return [];
|
||||
}
|
||||
|
||||
_logger.fine('Fetched ${seriesList.length} series');
|
||||
return seriesList;
|
||||
} catch (e, stackTrace) {
|
||||
_logger.severe('Error fetching series: $e', e, stackTrace);
|
||||
rethrow;
|
||||
}
|
||||
|
||||
_logger.fine('Fetched ${seriesList.length} series');
|
||||
return seriesList;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,20 @@ class LibrarySeriesPage extends HookConsumerWidget {
|
|||
body: seriesAsync.when(
|
||||
data: (seriesList) {
|
||||
if (seriesList.isEmpty) {
|
||||
return const Center(
|
||||
child: Text('No series found'),
|
||||
return Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.library_books_outlined, size: 48),
|
||||
const SizedBox(height: 16),
|
||||
const Text('No series found'),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'Check logs for API response details',
|
||||
style: Theme.of(context).textTheme.bodySmall,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -37,13 +49,25 @@ class LibrarySeriesPage extends HookConsumerWidget {
|
|||
child: CircularProgressIndicator(),
|
||||
),
|
||||
error: (error, stack) => Center(
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, size: 48, color: Colors.red),
|
||||
const SizedBox(height: 16),
|
||||
Text('Error loading series: $error'),
|
||||
],
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Icon(Icons.error_outline, size: 48, color: Colors.red),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
'Error loading series:',
|
||||
style: Theme.of(context).textTheme.titleMedium,
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
'$error',
|
||||
textAlign: TextAlign.center,
|
||||
style: Theme.of(context).textTheme.bodyMedium,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue