From 7bdf8ea2b02846d507dd7b6adb11f581497e77e9 Mon Sep 17 00:00:00 2001 From: jld3103 Date: Wed, 30 Nov 2022 13:56:43 +0100 Subject: [PATCH] neon: Always print stack traces on error --- packages/neon/lib/src/apps/files/blocs/files.dart | 4 +++- packages/neon/lib/src/blocs/login.dart | 6 ++++-- packages/neon/lib/src/pages/home.dart | 3 ++- packages/neon/lib/src/pages/settings.dart | 4 ++-- packages/neon/lib/src/utils/request_manager.dart | 15 +++++++++------ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/neon/lib/src/apps/files/blocs/files.dart b/packages/neon/lib/src/apps/files/blocs/files.dart index c643a7c4..5e39ce49 100644 --- a/packages/neon/lib/src/apps/files/blocs/files.dart +++ b/packages/neon/lib/src/apps/files/blocs/files.dart @@ -194,7 +194,9 @@ class FilesBloc extends $FilesBloc { await _downloadQueue.add(() => task.execute(client, sink)); _downloadTasksSubject.add(_downloadTasksSubject.value..removeWhere((final t) => t == task)); await sink.close(); - } catch (e) { + } catch (e, s) { + debugPrint(e.toString()); + debugPrint(s.toString()); await sink.close(); rethrow; } diff --git a/packages/neon/lib/src/blocs/login.dart b/packages/neon/lib/src/blocs/login.dart index 98b6f531..f156fbb7 100644 --- a/packages/neon/lib/src/blocs/login.dart +++ b/packages/neon/lib/src/blocs/login.dart @@ -56,12 +56,14 @@ class LoginBloc extends $LoginBloc { final result = await client.core.getLoginFlowResult(token: init.poll.token); _cancelPollTimer(); _loginFlowResultSubject.add(result); - } catch (e) { + } catch (e, s) { debugPrint(e.toString()); + debugPrint(s.toString()); } }); - } catch (e) { + } catch (e, s) { debugPrint(e.toString()); + debugPrint(s.toString()); _serverConnectionStateSubject.add(ServerConnectionState.unreachable); } } diff --git a/packages/neon/lib/src/pages/home.dart b/packages/neon/lib/src/pages/home.dart index cc4d716c..39d0544b 100644 --- a/packages/neon/lib/src/pages/home.dart +++ b/packages/neon/lib/src/pages/home.dart @@ -95,8 +95,9 @@ class _HomePageState extends State { AppLocalizations.of(context).errorServerInMaintenanceMode, ); } - } catch (e) { + } catch (e, s) { debugPrint(e.toString()); + debugPrint(s.toString()); ExceptionWidget.showSnackbar(context, e); } } diff --git a/packages/neon/lib/src/pages/settings.dart b/packages/neon/lib/src/pages/settings.dart index 325adeb8..00ddc3e0 100644 --- a/packages/neon/lib/src/pages/settings.dart +++ b/packages/neon/lib/src/pages/settings.dart @@ -259,7 +259,7 @@ class _SettingsPageState extends State { await saveFileWithPickDialog(fileName, Uint8List.fromList(utf8.encode(data))); } catch (e, s) { debugPrint(e.toString()); - debugPrintStack(stackTrace: s); + debugPrint(s.toString()); ExceptionWidget.showSnackbar(context, e); } }, @@ -295,7 +295,7 @@ class _SettingsPageState extends State { await settingsExportHelper.applyFromJson(data as Map); } catch (e, s) { debugPrint(e.toString()); - debugPrintStack(stackTrace: s); + debugPrint(s.toString()); ExceptionWidget.showSnackbar(context, e); } }, diff --git a/packages/neon/lib/src/utils/request_manager.dart b/packages/neon/lib/src/utils/request_manager.dart index cd0ad8bf..3a93c4d6 100644 --- a/packages/neon/lib/src/utils/request_manager.dart +++ b/packages/neon/lib/src/utils/request_manager.dart @@ -14,8 +14,9 @@ class RequestManager { yield Result.loading(); try { yield Result.success(await _timeout(disableTimeout, call)); - } on Exception catch (e) { + } on Exception catch (e, s) { debugPrint(e.toString()); + debugPrint(s.toString()); yield Result.error(e); } } @@ -39,8 +40,9 @@ class RequestManager { if (cache != null && await cache!.has(key)) { try { yield ResultCached(unwrap(deserialize(json.decode((await cache!.get(key))!))), loading: true); - } catch (e) { + } catch (e, s) { debugPrint(e.toString()); + debugPrint(s.toString()); } } @@ -48,17 +50,18 @@ class RequestManager { final response = await _timeout(disableTimeout, call); await cache?.set(key, json.encode(serialize(response))); yield Result.success(unwrap(response)); - } on Exception catch (e) { + } on Exception catch (e, s) { + debugPrint(e.toString()); + debugPrint(s.toString()); if (cache != null && await cache!.has(key)) { - debugPrint(e.toString()); try { yield ResultCached(unwrap(deserialize(json.decode((await cache!.get(key))!))), loading: true); return; - } catch (e) { + } catch (e, s) { debugPrint(e.toString()); + debugPrint(s.toString()); } } - debugPrint(e.toString()); yield Result.error(e); } }