From 8b12bf79e4d63a7535863a1eaeec40cd8aff4e32 Mon Sep 17 00:00:00 2001 From: Fil Maj Date: Wed, 15 Feb 2012 16:47:32 -0800 Subject: [PATCH] Unifying File API error code/response style --- .../src/org/apache/cordova/FileUtils.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/framework/src/org/apache/cordova/FileUtils.java b/framework/src/org/apache/cordova/FileUtils.java index 47bafee3..b397f046 100755 --- a/framework/src/org/apache/cordova/FileUtils.java +++ b/framework/src/org/apache/cordova/FileUtils.java @@ -199,32 +199,23 @@ public class FileUtils extends Plugin { } return new PluginResult(status, result); } catch (FileNotFoundException e) { - JSONObject error = new JSONObject().put("code", FileUtils.NOT_FOUND_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.NOT_FOUND_ERR); } catch (FileExistsException e) { - JSONObject error = new JSONObject().put("code", FileUtils.PATH_EXISTS_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.PATH_EXISTS_ERR); } catch (NoModificationAllowedException e) { - JSONObject error = new JSONObject().put("code", FileUtils.NO_MODIFICATION_ALLOWED_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.NO_MODIFICATION_ALLOWED_ERR); } catch (JSONException e) { - JSONObject error = new JSONObject().put("code", FileUtils.NO_MODIFICATION_ALLOWED_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.NO_MODIFICATION_ALLOWED_ERR); } catch (InvalidModificationException e) { - JSONObject error = new JSONObject().put("code", FileUtils.INVALID_MODIFICATION_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.INVALID_MODIFICATION_ERR); } catch (MalformedURLException e) { - JSONObject error = new JSONObject().put("code", FileUtils.ENCODING_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.ENCODING_ERR); } catch (IOException e) { - JSONObject error = new JSONObject().put("code", FileUtils.INVALID_MODIFICATION_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.INVALID_MODIFICATION_ERR); } catch (EncodingException e) { - JSONObject error = new JSONObject().put("code", FileUtils.ENCODING_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.ENCODING_ERR); } catch (TypeMismatchException e) { - JSONObject error = new JSONObject().put("code", FileUtils.TYPE_MISMATCH_ERR); - return new PluginResult(PluginResult.Status.ERROR, error); + return new PluginResult(PluginResult.Status.ERROR, FileUtils.TYPE_MISMATCH_ERR); } } catch (JSONException e) { e.printStackTrace();