mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 18:38:36 +08:00
Catch possible exceptions when creating the fileName
This can apparently happen, and we should have a fallback. Additionally Dart has both an 'Error' and an 'Exception' which are two different things. This makes no sense.
This commit is contained in:
@ -75,7 +75,13 @@ class Note with NotesNotifier {
|
||||
|
||||
String get filePath {
|
||||
if (_filePath == null) {
|
||||
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')) {
|
||||
|
@ -100,7 +100,10 @@ Future<void> reportError(Object error, StackTrace stackTrace) async {
|
||||
print(stackTrace);
|
||||
}
|
||||
|
||||
Future<void> logException(Exception e, StackTrace stackTrace) async {
|
||||
// Dart makes a distiction between Errors and Exceptions
|
||||
// so we need to use dynamic
|
||||
Future<void> logException(Object e, StackTrace stackTrace) async {
|
||||
assert(e is Exception || e is Error);
|
||||
if (!reportCrashes) {
|
||||
return;
|
||||
}
|
||||
@ -109,7 +112,8 @@ Future<void> logException(Exception e, StackTrace stackTrace) async {
|
||||
return FlutterCrashlytics().logException(e, stackTrace);
|
||||
}
|
||||
|
||||
Future<void> logExceptionWarning(Exception e, StackTrace stackTrace) async {
|
||||
Future<void> logExceptionWarning(Object e, StackTrace stackTrace) async {
|
||||
assert(e is Exception || e is Error);
|
||||
if (!reportCrashes) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user