mirror of
https://github.com/apache/cordova-android.git
synced 2025-01-19 15:12:51 +08:00
Globalization plugin should return an error object and not a code
This commit is contained in:
parent
1b4096b01d
commit
4021f26e76
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user