tuanpmt/react-native-smartconfig

Unhandled promise rejection

hdrut opened this issue · 0 comments

hdrut commented

I had to add a try-catch block in this module and throw an exception to handle case when Smartconfig is not successful :

        try{
          for (IEsptouchResult resultInList : result) {
            if(!resultInList.isCancelled() && resultInList.getBssid() != null) {
              WritableMap map = Arguments.createMap();
              map.putString("bssid", resultInList.getBssid());
              map.putString("ipv4", resultInList.getInetAddress().getHostAddress());
              ret.pushMap(map);
              resolved = true;                  
              if (!resultInList.isSuc()) {
                //Log.d(TAG, "Not successful!");
                break;                    
              }                
            }
          }
          if(resolved) {
            Log.d(TAG, "Success in Smartconfig run");
            promise.resolve(ret);
          } else {
            //Log.d(TAG, " " + resolved);
            throw new Exception();
          }
        } catch(Exception e){ 
            Log.d(TAG, "Error, Smartconfig could not complete!");
            promise.reject("new Exception()", e);
          }