diff --git a/framework/src/org/apache/cordova/Globalization.java b/framework/src/org/apache/cordova/Globalization.java index 7d724c94..98bf9e5a 100644 --- a/framework/src/org/apache/cordova/Globalization.java +++ b/framework/src/org/apache/cordova/Globalization.java @@ -128,7 +128,7 @@ public class Globalization extends Plugin { return new PluginResult(PluginResult.Status.OK, obj); } }catch (GlobalizationError ge){ - return new PluginResult(PluginResult.Status.ERROR, ge.getErrorCode()); + return new PluginResult(PluginResult.Status.ERROR, ge.toJson()); }catch (Exception e){ return new PluginResult(PluginResult.Status.JSON_EXCEPTION); } diff --git a/framework/src/org/apache/cordova/GlobalizationError.java b/framework/src/org/apache/cordova/GlobalizationError.java index 5c1b09e7..8a171d42 100644 --- a/framework/src/org/apache/cordova/GlobalizationError.java +++ b/framework/src/org/apache/cordova/GlobalizationError.java @@ -19,6 +19,9 @@ package org.apache.cordova; +import org.json.JSONException; +import org.json.JSONObject; + /** * @description Exception class representing defined Globalization error codes * @Globalization error codes: @@ -88,4 +91,18 @@ public class GlobalizationError extends Exception{ return error; } + /** + * get the json version of this object to return to javascript + * @return + */ + public JSONObject toJson() { + JSONObject obj = new JSONObject(); + try { + obj.put("code", getErrorCode()); + obj.put("message", getErrorString()); + } catch (JSONException e) { + // never happens + } + return obj; + } }