mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-30 11:33:34 +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 {
|
String get filePath {
|
||||||
if (_filePath == null) {
|
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) {
|
switch (_fileFormat) {
|
||||||
case NoteFileFormat.Txt:
|
case NoteFileFormat.Txt:
|
||||||
if (!_filePath.toLowerCase().endsWith('.txt')) {
|
if (!_filePath.toLowerCase().endsWith('.txt')) {
|
||||||
|
@ -100,7 +100,10 @@ Future<void> reportError(Object error, StackTrace stackTrace) async {
|
|||||||
print(stackTrace);
|
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) {
|
if (!reportCrashes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -109,7 +112,8 @@ Future<void> logException(Exception e, StackTrace stackTrace) async {
|
|||||||
return FlutterCrashlytics().logException(e, stackTrace);
|
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) {
|
if (!reportCrashes) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user