mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-04-18 14:35:53 -04:00
remove things that fail to deserialize
This commit is contained in:
parent
2344184620
commit
f8977147f6
@ -40,6 +40,13 @@ sealed class LocalAccount with _$LocalAccount {
|
||||
required String name,
|
||||
}) = _LocalAccount;
|
||||
|
||||
factory LocalAccount.fromJson(dynamic json) =>
|
||||
_$LocalAccountFromJson(json as Map<String, dynamic>);
|
||||
factory LocalAccount.fromJson(dynamic json) {
|
||||
try {
|
||||
return _$LocalAccountFromJson(json as Map<String, dynamic>);
|
||||
// Need to catch any errors here too
|
||||
// ignore: avoid_catches_without_on_clauses
|
||||
} catch (e, st) {
|
||||
throw Exception('invalid local account: $e\n$st');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,13 @@ sealed class UserLogin with _$UserLogin {
|
||||
required Timestamp lastActive,
|
||||
}) = _UserLogin;
|
||||
|
||||
factory UserLogin.fromJson(dynamic json) =>
|
||||
_$UserLoginFromJson(json as Map<String, dynamic>);
|
||||
factory UserLogin.fromJson(dynamic json) {
|
||||
try {
|
||||
return _$UserLoginFromJson(json as Map<String, dynamic>);
|
||||
// Need to catch any errors here too
|
||||
// ignore: avoid_catches_without_on_clauses
|
||||
} catch (e, st) {
|
||||
throw Exception('invalid user login: $e\n$st');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,9 @@ import 'package:async_tools/async_tools.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:veilid/veilid.dart';
|
||||
|
||||
import '../veilid_support.dart';
|
||||
import 'veilid_log.dart';
|
||||
|
||||
Future<T> tableScope<T>(
|
||||
String name, Future<T> Function(VeilidTableDB tdb) callback,
|
||||
{int columnCount = 1}) async {
|
||||
@ -48,11 +51,20 @@ abstract mixin class TableDBBackedJson<T> {
|
||||
/// Load things from storage
|
||||
@protected
|
||||
Future<T?> load() async {
|
||||
final obj = await tableScope(tableName(), (tdb) async {
|
||||
final objJson = await tdb.loadStringJson(0, tableKeyName());
|
||||
return valueFromJson(objJson);
|
||||
});
|
||||
return obj;
|
||||
try {
|
||||
final obj = await tableScope(tableName(), (tdb) async {
|
||||
final objJson = await tdb.loadStringJson(0, tableKeyName());
|
||||
return valueFromJson(objJson);
|
||||
});
|
||||
return obj;
|
||||
} on Exception catch (e, st) {
|
||||
veilidLoggy.debug(
|
||||
'Unable to load data from table store: '
|
||||
'${tableName()}:${tableKeyName()}',
|
||||
e,
|
||||
st);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// Store things to storage
|
||||
|
@ -69,6 +69,7 @@ void processLog(VeilidLog log) {
|
||||
}
|
||||
|
||||
void initVeilidLog(bool debugMode) {
|
||||
// Always allow LOG_TRACE option
|
||||
// ignore: do_not_use_environment
|
||||
const isTrace = String.fromEnvironment('LOG_TRACE') != '';
|
||||
LogLevel logLevel;
|
||||
|
Loading…
x
Reference in New Issue
Block a user