File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import "bindings/bindings.dart";
44import "bindings/helpers.dart" ;
55import "modelinfo/index.dart" ;
66import "model.dart" ;
7+ import "common.dart" ;
78
89enum TxMode {
910 Read ,
@@ -40,7 +41,23 @@ class Store {
4041 rethrow ;
4142 }
4243 _cStore = bindings.obx_store_open (opt);
43- checkObxPtr (_cStore, "failed to create store" );
44+
45+ try {
46+ checkObxPtr (_cStore, "failed to create store" );
47+ } on ObjectBoxException catch (e) {
48+ // Recognize common problems when trying to open/create a database
49+ // 10199 = OBX_ERROR_STORAGE_GENERAL
50+ if (e.nativeCode == 10199 && e.nativeMsg != null && e.nativeMsg.contains ('Dir does not exist' )) {
51+ // 13 = permissions denied, 30 = read-only filesystem
52+ if (e.nativeMsg.endsWith (' (13)' ) || e.nativeMsg.endsWith (' (30)' )) {
53+ final msg = e.nativeMsg +
54+ " - this usually indicates a problem with permissions; if you're using Flutter you may need to use " +
55+ "getApplicationDocumentsDirectory() from the path_provider package, see example/README.md" ;
56+ throw ObjectBoxException (dartMsg: e.dartMsg, nativeCode: e.nativeCode, nativeMsg: msg);
57+ }
58+ }
59+ rethrow ;
60+ }
4461 }
4562
4663 /// Closes this store.
You can’t perform that action at this time.
0 commit comments