diff --git a/lib/app/lists.dart b/lib/app/lists.dart index 154b1a1..3b5c552 100644 --- a/lib/app/lists.dart +++ b/lib/app/lists.dart @@ -4,6 +4,7 @@ import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart'; import '../services/sync_service.dart'; import 'items.dart'; +import 'snackbars.dart'; class PagedListQueryView extends HookConsumerWidget { final PagingController pagingController; @@ -122,7 +123,13 @@ class SyncAllRefresh extends HookConsumerWidget { @override Widget build(BuildContext context, WidgetRef ref) { return RefreshIndicator( - onRefresh: () => ref.read(syncServiceProvider.notifier).syncAll(), + onRefresh: () async { + try { + await ref.read(syncServiceProvider.notifier).syncAll(); + } catch (e) { + showErrorSnackbar(context, e.toString()); + } + }, child: child, ); } diff --git a/lib/http/client.dart b/lib/http/client.dart index f4f32aa..75ac69d 100644 --- a/lib/http/client.dart +++ b/lib/http/client.dart @@ -16,7 +16,14 @@ class SubtracksHttpClient extends BaseClient { Future send(BaseRequest request) { request.headers.addAll(subtracksHeaders); log.info('${request.method} ${_redactUri(request.url)}'); - return request.send(); + + try { + return request.send(); + } catch (e, st) { + log.severe( + 'HTTP client: ${request.method} ${_redactUri(request.url)}', e, st); + rethrow; + } } } diff --git a/lib/services/audio_service.dart b/lib/services/audio_service.dart index e48bd91..8a8ce80 100644 --- a/lib/services/audio_service.dart +++ b/lib/services/audio_service.dart @@ -95,36 +95,36 @@ class AudioControl extends BaseAudioHandler with QueueHandler, SeekHandler { int get _sourceId => _ref.read(sourceIdProvider); AudioControl(this._player, this._ref) { - _player.playbackEventStream.listen( - (PlaybackEvent event) { - final playing = _player.playing; - playbackState.add(playbackState.value.copyWith( - controls: [ - MediaControl.skipToPrevious, - if (playing) MediaControl.pause else MediaControl.play, - MediaControl.stop, - MediaControl.skipToNext, - ], - systemActions: const { - MediaAction.seek, - }, - androidCompactActionIndices: const [0, 1, 3], - processingState: const { - ProcessingState.idle: AudioProcessingState.idle, - ProcessingState.loading: AudioProcessingState.loading, - ProcessingState.buffering: AudioProcessingState.buffering, - ProcessingState.ready: AudioProcessingState.ready, - ProcessingState.completed: AudioProcessingState.completed, - }[_player.processingState]!, - playing: playing, - updatePosition: _player.position, - bufferedPosition: _player.bufferedPosition, - queueIndex: event.currentIndex, - )); - }, - onError: (e, st) => log.warning('Audio playback error', e, st), - cancelOnError: false, - ); + _player.playbackEventStream.listen((PlaybackEvent event) { + final playing = _player.playing; + playbackState.add(playbackState.value.copyWith( + controls: [ + MediaControl.skipToPrevious, + if (playing) MediaControl.pause else MediaControl.play, + MediaControl.stop, + MediaControl.skipToNext, + ], + systemActions: const { + MediaAction.seek, + }, + androidCompactActionIndices: const [0, 1, 3], + processingState: const { + ProcessingState.idle: AudioProcessingState.idle, + ProcessingState.loading: AudioProcessingState.loading, + ProcessingState.buffering: AudioProcessingState.buffering, + ProcessingState.ready: AudioProcessingState.ready, + ProcessingState.completed: AudioProcessingState.completed, + }[_player.processingState]!, + playing: playing, + updatePosition: _player.position, + bufferedPosition: _player.bufferedPosition, + queueIndex: event.currentIndex, + )); + }); + + _player.playbackEventStream.doOnError((e, st) async { + log.warning('playbackEventStream', e, st); + }); shuffleIndicies.listen((value) { playbackState.add(playbackState.value.copyWith( diff --git a/lib/sources/music_source.dart b/lib/sources/music_source.dart index f89abbd..bb4af44 100644 --- a/lib/sources/music_source.dart +++ b/lib/sources/music_source.dart @@ -1,6 +1,8 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; +import 'package:rxdart/rxdart.dart'; import '../database/database.dart'; +import '../log.dart'; import '../state/settings.dart'; abstract class BaseMusicSource { @@ -40,25 +42,33 @@ class MusicSource implements BaseMusicSource { @override Stream> allAlbums() { _testOnline(); - return _source.allAlbums(); + return _source + .allAlbums() + .doOnError((e, st) => log.severe('allAlbums', e, st)); } @override Stream> allArtists() { _testOnline(); - return _source.allArtists(); + return _source + .allArtists() + .doOnError((e, st) => log.severe('allArtists', e, st)); } @override Stream> allPlaylists() { _testOnline(); - return _source.allPlaylists(); + return _source + .allPlaylists() + .doOnError((e, st) => log.severe('allPlaylists', e, st)); } @override Stream> allSongs() { _testOnline(); - return _source.allSongs(); + return _source + .allSongs() + .doOnError((e, st) => log.severe('allSongs', e, st)); } @override