diff --git a/lib/core/note.dart b/lib/core/note.dart index a60df64f..558b921b 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -75,7 +75,13 @@ class Note with NotesNotifier { String get filePath { if (_filePath == null) { - _filePath = p.join(parent.folderPath, _buildFileName()); + try { + _filePath = p.join(parent.folderPath, _buildFileName()); + } catch (e, stackTrace) { + Log.e("_buildFileName: $e"); + logExceptionWarning(e, stackTrace); + _filePath = p.join(parent.folderPath, Uuid().v4()); + } switch (_fileFormat) { case NoteFileFormat.Txt: if (!_filePath.toLowerCase().endsWith('.txt')) { diff --git a/lib/error_reporting.dart b/lib/error_reporting.dart index 7c9d2d74..48e6ebc5 100644 --- a/lib/error_reporting.dart +++ b/lib/error_reporting.dart @@ -100,7 +100,10 @@ Future reportError(Object error, StackTrace stackTrace) async { print(stackTrace); } -Future logException(Exception e, StackTrace stackTrace) async { +// Dart makes a distiction between Errors and Exceptions +// so we need to use dynamic +Future logException(Object e, StackTrace stackTrace) async { + assert(e is Exception || e is Error); if (!reportCrashes) { return; } @@ -109,7 +112,8 @@ Future logException(Exception e, StackTrace stackTrace) async { return FlutterCrashlytics().logException(e, stackTrace); } -Future logExceptionWarning(Exception e, StackTrace stackTrace) async { +Future logExceptionWarning(Object e, StackTrace stackTrace) async { + assert(e is Exception || e is Error); if (!reportCrashes) { return; }