explainMissingSqliteModules<T> function
Runs the action opening a database, explaining failures due to modules
missing in the SQLite library.
Implementation
Future<T> explainMissingSqliteModules<T>(Future<T> Function() action) async {
try {
return await action();
// not other exceptions of callbacks, which may mention modules
} on DatabaseException catch (exception, stackTrace) {
final module = RegExp(r'no such module: (\w+)')
.firstMatch(exception.toString())
?.group(1);
if (module == null) rethrow;
Error.throwWithStackTrace(
MissingSqliteModuleException(module, exception),
stackTrace,
);
}
}