@@ -438,6 +438,10 @@ public void getAccount(Promise promise) {
438438 ThreadUtils .runOnExecutor (() -> {
439439 Log .d ("ReactNative" , "getAccount called " );
440440 try {
441+ if (this .fula == null ) {
442+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
443+ return ;
444+ }
441445 byte [] result = this .fula .getAccount ();
442446 String resultString = toString (result );
443447 promise .resolve (resultString );
@@ -453,6 +457,10 @@ public void accountFund(String accountString, Promise promise) {
453457 ThreadUtils .runOnExecutor (() -> {
454458 Log .d ("ReactNative" , "accountFund: accountString = " + accountString );
455459 try {
460+ if (this .fula == null ) {
461+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
462+ return ;
463+ }
456464 byte [] result = this .fula .accountFund (accountString );
457465 String resultString = toString (result );
458466 promise .resolve (resultString );
@@ -470,6 +478,10 @@ public void assetsBalance(String account, String assetId, String classId, Promis
470478 ThreadUtils .runOnExecutor (() -> {
471479 Log .d ("ReactNative" , "assetsBalance called " );
472480 try {
481+ if (this .fula == null ) {
482+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
483+ return ;
484+ }
473485 byte [] result = this .fula .assetsBalance (account , assetIdLong , classIdLong );
474486 String resultString = toString (result );
475487 promise .resolve (resultString );
@@ -485,6 +497,10 @@ public void transferToFula(String amount, String wallet, String chain, Promise p
485497 ThreadUtils .runOnExecutor (() -> {
486498 Log .d ("ReactNative" , "transferToFula called " );
487499 try {
500+ if (this .fula == null ) {
501+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
502+ return ;
503+ }
488504 byte [] result = this .fula .transferToFula (amount , wallet , chain );
489505 String resultString = toString (result );
490506 promise .resolve (resultString );
@@ -500,6 +516,10 @@ public void checkAccountExists(String accountString, Promise promise) {
500516 ThreadUtils .runOnExecutor (() -> {
501517 Log .d ("ReactNative" , "checkAccountExists: accountString = " + accountString );
502518 try {
519+ if (this .fula == null ) {
520+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
521+ return ;
522+ }
503523 byte [] result = this .fula .accountExists (accountString );
504524 String resultString = toString (result );
505525 promise .resolve (resultString );
@@ -515,6 +535,10 @@ public void listPools(Promise promise) {
515535 ThreadUtils .runOnExecutor (() -> {
516536 Log .d ("ReactNative" , "listPools" );
517537 try {
538+ if (this .fula == null ) {
539+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
540+ return ;
541+ }
518542 byte [] result = this .fula .poolList ();
519543 String resultString = toString (result );
520544 promise .resolve (resultString );
@@ -531,6 +555,10 @@ public void joinPool(String poolID, Promise promise) {
531555 long poolIdLong = Long .parseLong (poolID );
532556 Log .d ("ReactNative" , "joinPool: poolID = " + poolIdLong );
533557 try {
558+ if (this .fula == null ) {
559+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
560+ return ;
561+ }
534562 byte [] result = this .fula .poolJoin (poolIdLong );
535563 String resultString = toString (result );
536564 promise .resolve (resultString );
@@ -547,6 +575,10 @@ public void cancelPoolJoin(String poolID, Promise promise) {
547575 long poolIdLong = Long .parseLong (poolID );
548576 Log .d ("ReactNative" , "cancelPoolJoin: poolID = " + poolIdLong );
549577 try {
578+ if (this .fula == null ) {
579+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
580+ return ;
581+ }
550582 byte [] result = this .fula .poolCancelJoin (poolIdLong );
551583 String resultString = toString (result );
552584 promise .resolve (resultString );
@@ -562,6 +594,10 @@ public void listPoolJoinRequests(String poolIDStr, Promise promise) {
562594 ThreadUtils .runOnExecutor (() -> {
563595 Log .d ("ReactNative" , "listPoolJoinRequests: poolID = " + poolIDStr );
564596 try {
597+ if (this .fula == null ) {
598+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
599+ return ;
600+ }
565601 long poolID = Long .parseLong (poolIDStr );
566602 byte [] result = this .fula .poolRequests (poolID );
567603 String resultString = toString (result );
@@ -579,6 +615,10 @@ public void leavePool(String poolID, Promise promise) {
579615 long poolIdLong = Long .parseLong (poolID );
580616 Log .d ("ReactNative" , "leavePool: poolID = " + poolIdLong );
581617 try {
618+ if (this .fula == null ) {
619+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
620+ return ;
621+ }
582622 byte [] result = this .fula .poolLeave (poolIdLong );
583623 String resultString = toString (result );
584624 promise .resolve (resultString );
@@ -660,6 +700,10 @@ public void listAvailableReplicationRequests(String poolIDStr, Promise promise)
660700 ThreadUtils .runOnExecutor (() -> {
661701 Log .d ("ReactNative" , "listAvailableReplicationRequests: poolID = " + poolIDStr );
662702 try {
703+ if (this .fula == null ) {
704+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
705+ return ;
706+ }
663707 long poolID = Long .parseLong (poolIDStr );
664708 byte [] result = this .fula .manifestAvailable (poolID );
665709 String resultString = toString (result );
@@ -736,6 +780,10 @@ public void bloxFreeSpace(Promise promise) {
736780 ThreadUtils .runOnExecutor (() -> {
737781 Log .d ("ReactNative" , "bloxFreeSpace" );
738782 try {
783+ if (this .fula == null ) {
784+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
785+ return ;
786+ }
739787 byte [] result = this .fula .bloxFreeSpace ();
740788 String resultString = toString (result );
741789 Log .d ("ReactNative" , "result string=" +resultString );
@@ -752,6 +800,10 @@ public void wifiRemoveall(Promise promise) {
752800 ThreadUtils .runOnExecutor (() -> {
753801 Log .d ("ReactNative" , "wifiRemoveall" );
754802 try {
803+ if (this .fula == null ) {
804+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
805+ return ;
806+ }
755807 byte [] result = this .fula .wifiRemoveall ();
756808 String resultString = toString (result );
757809 Log .d ("ReactNative" , "result string=" +resultString );
@@ -768,6 +820,10 @@ public void fetchContainerLogs(String containerName, String tailCount, Promise p
768820 ThreadUtils .runOnExecutor (() -> {
769821 Log .d ("ReactNative" , "fetchContainerLogs" );
770822 try {
823+ if (this .fula == null ) {
824+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
825+ return ;
826+ }
771827 byte [] result = this .fula .fetchContainerLogs (containerName , tailCount );
772828 String resultString = toString (result );
773829 Log .d ("ReactNative" , "result string=" +resultString );
@@ -784,6 +840,10 @@ public void findBestAndTargetInLogs(String containerName, String tailCount, Prom
784840 ThreadUtils .runOnExecutor (() -> {
785841 Log .d ("ReactNative" , "findBestAndTargetInLogs" );
786842 try {
843+ if (this .fula == null ) {
844+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
845+ return ;
846+ }
787847 byte [] result = this .fula .findBestAndTargetInLogs (containerName , tailCount );
788848 String resultString = toString (result );
789849 Log .d ("ReactNative" , "result string=" +resultString );
@@ -800,6 +860,10 @@ public void getFolderSize(String folderPath, Promise promise) {
800860 ThreadUtils .runOnExecutor (() -> {
801861 Log .d ("ReactNative" , "getFolderSize" );
802862 try {
863+ if (this .fula == null ) {
864+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
865+ return ;
866+ }
803867 byte [] result = this .fula .getFolderSize (folderPath );
804868 String resultString = toString (result );
805869 Log .d ("ReactNative" , "result string=" +resultString );
@@ -816,6 +880,10 @@ public void getDatastoreSize(Promise promise) {
816880 ThreadUtils .runOnExecutor (() -> {
817881 Log .d ("ReactNative" , "getDatastoreSize" );
818882 try {
883+ if (this .fula == null ) {
884+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
885+ return ;
886+ }
819887 byte [] result = this .fula .getDatastoreSize ();
820888 String resultString = toString (result );
821889 Log .d ("ReactNative" , "result string=" +resultString );
@@ -832,6 +900,10 @@ public void reboot(Promise promise) {
832900 ThreadUtils .runOnExecutor (() -> {
833901 Log .d ("ReactNative" , "reboot" );
834902 try {
903+ if (this .fula == null ) {
904+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
905+ return ;
906+ }
835907 byte [] result = this .fula .reboot ();
836908 String resultString = toString (result );
837909 Log .d ("ReactNative" , "result string=" +resultString );
@@ -848,6 +920,10 @@ public void partition(Promise promise) {
848920 ThreadUtils .runOnExecutor (() -> {
849921 Log .d ("ReactNative" , "partition" );
850922 try {
923+ if (this .fula == null ) {
924+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
925+ return ;
926+ }
851927 byte [] result = this .fula .partition ();
852928 String resultString = toString (result );
853929 Log .d ("ReactNative" , "result string=" +resultString );
@@ -864,6 +940,10 @@ public void eraseBlData(Promise promise) {
864940 ThreadUtils .runOnExecutor (() -> {
865941 Log .d ("ReactNative" , "eraseBlData" );
866942 try {
943+ if (this .fula == null ) {
944+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
945+ return ;
946+ }
867947 byte [] result = this .fula .eraseBlData ();
868948 String resultString = toString (result );
869949 Log .d ("ReactNative" , "result string=" +resultString );
@@ -881,6 +961,10 @@ public void listPlugins(Promise promise) {
881961 ThreadUtils .runOnExecutor (() -> {
882962 Log .d ("ReactNative" , "listPlugins" );
883963 try {
964+ if (this .fula == null ) {
965+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
966+ return ;
967+ }
884968 byte [] result = this .fula .listPlugins ();
885969 String resultString = toString (result );
886970 promise .resolve (resultString );
@@ -896,6 +980,10 @@ public void listActivePlugins(Promise promise) {
896980 ThreadUtils .runOnExecutor (() -> {
897981 Log .d ("ReactNative" , "listActivePlugins" );
898982 try {
983+ if (this .fula == null ) {
984+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
985+ return ;
986+ }
899987 byte [] result = this .fula .listActivePlugins ();
900988 String resultString = toString (result );
901989 promise .resolve (resultString );
@@ -911,6 +999,10 @@ public void installPlugin(String pluginName, String params, Promise promise) {
911999 ThreadUtils .runOnExecutor (() -> {
9121000 Log .d ("ReactNative" , "installPlugin: pluginName = " + pluginName + ", params = " + params );
9131001 try {
1002+ if (this .fula == null ) {
1003+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1004+ return ;
1005+ }
9141006 byte [] result = this .fula .installPlugin (pluginName , params );
9151007 String resultString = toString (result );
9161008 promise .resolve (resultString );
@@ -926,6 +1018,10 @@ public void uninstallPlugin(String pluginName, Promise promise) {
9261018 ThreadUtils .runOnExecutor (() -> {
9271019 Log .d ("ReactNative" , "uninstallPlugin: pluginName = " + pluginName );
9281020 try {
1021+ if (this .fula == null ) {
1022+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1023+ return ;
1024+ }
9291025 byte [] result = this .fula .uninstallPlugin (pluginName );
9301026 String resultString = toString (result );
9311027 promise .resolve (resultString );
@@ -941,6 +1037,10 @@ public void showPluginStatus(String pluginName, int lines, Promise promise) {
9411037 ThreadUtils .runOnExecutor (() -> {
9421038 Log .d ("ReactNative" , "showPluginStatus: pluginName = " + pluginName + ", lines = " + lines );
9431039 try {
1040+ if (this .fula == null ) {
1041+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1042+ return ;
1043+ }
9441044 byte [] result = this .fula .showPluginStatus (pluginName , lines );
9451045 String resultString = toString (result );
9461046 promise .resolve (resultString );
@@ -956,6 +1056,10 @@ public void getInstallOutput(String pluginName, String params, Promise promise)
9561056 ThreadUtils .runOnExecutor (() -> {
9571057 Log .d ("ReactNative" , "getInstallOutput: pluginName = " + pluginName + ", params = " + params );
9581058 try {
1059+ if (this .fula == null ) {
1060+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1061+ return ;
1062+ }
9591063 byte [] result = this .fula .getInstallOutput (pluginName , params );
9601064 String resultString = toString (result );
9611065 promise .resolve (resultString );
@@ -971,6 +1075,10 @@ public void getInstallStatus(String pluginName, Promise promise) {
9711075 ThreadUtils .runOnExecutor (() -> {
9721076 Log .d ("ReactNative" , "getInstallStatus: pluginName = " + pluginName );
9731077 try {
1078+ if (this .fula == null ) {
1079+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1080+ return ;
1081+ }
9741082 byte [] result = this .fula .getInstallStatus (pluginName );
9751083 String resultString = toString (result );
9761084 promise .resolve (resultString );
@@ -986,6 +1094,10 @@ public void updatePlugin(String pluginName, Promise promise) {
9861094 ThreadUtils .runOnExecutor (() -> {
9871095 Log .d ("ReactNative" , "updatePlugin: pluginName = " + pluginName );
9881096 try {
1097+ if (this .fula == null ) {
1098+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1099+ return ;
1100+ }
9891101 byte [] result = this .fula .updatePlugin (pluginName );
9901102 String resultString = toString (result );
9911103 promise .resolve (resultString );
@@ -1002,6 +1114,10 @@ public void chatWithAI(String aiModel, String userMessage, Promise promise) {
10021114 ThreadUtils .runOnExecutor (() -> {
10031115 Log .d ("ReactNative" , "chatWithAI: aiModel = " + aiModel + ", userMessage = " + userMessage );
10041116 try {
1117+ if (this .fula == null ) {
1118+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1119+ return ;
1120+ }
10051121 // Call the Go Mobile method, which returns a byte[]
10061122 byte [] streamIDBytes = this .fula .chatWithAI (aiModel , userMessage );
10071123
@@ -1022,6 +1138,10 @@ public void getChatChunk(String streamID, Promise promise) {
10221138 ThreadUtils .runOnExecutor (() -> {
10231139 Log .d ("ReactNative" , "getChatChunk: streamID = " + streamID );
10241140 try {
1141+ if (this .fula == null ) {
1142+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1143+ return ;
1144+ }
10251145 // Call the Go Mobile method, which returns a String
10261146 String chunk = this .fula .getChatChunk (streamID );
10271147
@@ -1052,6 +1172,10 @@ public void streamChunks(String streamID, Promise promise) {
10521172
10531173 ThreadUtils .runOnExecutor (() -> {
10541174 try {
1175+ if (this .fula == null ) {
1176+ promise .reject ("ERR_FULA" , "Fula is not initialized" );
1177+ return ;
1178+ }
10551179 fulamobile .StreamIterator iterator = this .fula .getStreamIterator (streamID );
10561180
10571181 if (iterator == null ) {
0 commit comments