mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2026-02-22 17:29:35 +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 [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use raw API call to avoid Series deserialization issues
|
try {
|
||||||
final seriesList = await api.getJson<List<SimpleSeries>>(
|
// Use raw API call to avoid Series deserialization issues
|
||||||
path: '/api/libraries/${currentLibrary.id}/series',
|
final seriesList = await api.getJson<List<SimpleSeries>>(
|
||||||
requiresAuth: true,
|
path: '/api/libraries/${currentLibrary.id}/series',
|
||||||
fromJson: (json) {
|
requiresAuth: true,
|
||||||
if (json is Map<String, dynamic> && json.containsKey('results')) {
|
fromJson: (json) {
|
||||||
final results = json['results'] as List<dynamic>;
|
_logger.info('Series API response: $json');
|
||||||
return results
|
|
||||||
.map((e) => SimpleSeries.fromJson(e as Map<String, dynamic>))
|
|
||||||
.toList();
|
|
||||||
}
|
|
||||||
return <SimpleSeries>[];
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
if (seriesList == null) {
|
if (json is Map<String, dynamic>) {
|
||||||
_logger.warning('Failed to fetch series for library ${currentLibrary.id}');
|
if (json.containsKey('results')) {
|
||||||
return [];
|
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(
|
body: seriesAsync.when(
|
||||||
data: (seriesList) {
|
data: (seriesList) {
|
||||||
if (seriesList.isEmpty) {
|
if (seriesList.isEmpty) {
|
||||||
return const Center(
|
return Center(
|
||||||
child: Text('No series found'),
|
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(),
|
child: CircularProgressIndicator(),
|
||||||
),
|
),
|
||||||
error: (error, stack) => Center(
|
error: (error, stack) => Center(
|
||||||
child: Column(
|
child: Padding(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
padding: const EdgeInsets.all(16.0),
|
||||||
children: [
|
child: Column(
|
||||||
const Icon(Icons.error_outline, size: 48, color: Colors.red),
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
const SizedBox(height: 16),
|
children: [
|
||||||
Text('Error loading series: $error'),
|
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