mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
NotesCache: Allow for json decoding errors
The file may have gotten corrupted.
This commit is contained in:
@ -1,7 +1,9 @@
|
|||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
|
import 'package:fimber/fimber.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_crashlytics/flutter_crashlytics.dart';
|
||||||
import 'package:path/path.dart' as p;
|
import 'package:path/path.dart' as p;
|
||||||
import 'package:collection/collection.dart';
|
import 'package:collection/collection.dart';
|
||||||
|
|
||||||
@ -104,7 +106,13 @@ class NotesCache {
|
|||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
return json.decode(contents).cast<String>();
|
return json.decode(contents).cast<String>();
|
||||||
|
} catch (ex, st) {
|
||||||
|
Fimber.e("Exception - $ex for contents: $contents");
|
||||||
|
await FlutterCrashlytics().logException(ex, st);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@visibleForTesting
|
@visibleForTesting
|
||||||
|
Reference in New Issue
Block a user