diff --git a/src/android/CommunicationHelperPlugin.java b/src/android/CommunicationHelperPlugin.java index 3c67364..8a19b9d 100644 --- a/src/android/CommunicationHelperPlugin.java +++ b/src/android/CommunicationHelperPlugin.java @@ -24,11 +24,15 @@ public boolean execute(String action, JSONArray data, final CallbackContext call cordova.getThreadPool().execute(new Runnable() { public void run() { try { - String resultString = CommunicationHelper.pushGetJSON(ctxt, fullURL, filledMessage); - callbackContext.success(new JSONObject(resultString)); - } catch (Exception e) { - callbackContext.error("While pushing/getting from server "+e.getMessage()); - } + String resultString = CommunicationHelper.pushGetJSON(ctxt, fullURL, filledMessage); + callbackContext.success(new JSONObject(resultString)); + } catch (JSONException e) { + callbackContext.error("While pushing/getting from server, " + + "Response was not JSON: " + resultString + + " Exception: "+e.getMessage()); + } catch (Exception e) { + callbackContext.error("While pushing/getting from server, "+e.getMessage()); + } } }); } catch (Exception e) { diff --git a/src/ios/BEMCommunicationHelperPlugin.m b/src/ios/BEMCommunicationHelperPlugin.m index 7fe7818..bb1d4ed 100644 --- a/src/ios/BEMCommunicationHelperPlugin.m +++ b/src/ios/BEMCommunicationHelperPlugin.m @@ -21,7 +21,10 @@ - (void)pushGetJSON:(CDVInvokedUrlCommand *)command options:kNilOptions error: &parseError]; if (parseError != NULL) { - [self sendError:parseError callBackID:callbackId]; + NSString *msg = [NSString stringWithFormat: @"Response was not JSON: %@ Error: %@", + [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding], + parseError]; + [self sendError:msg callBackID:callbackId]; } CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK