cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [4/9] js commit: [all] Use argscheck in resolveLocalFileSystemURI.
Date Thu, 22 Nov 2012 20:47:47 GMT
[all] Use argscheck in resolveLocalFileSystemURI.

Also removes a redundant try/catch in the callback.
https://issues.apache.org/jira/browse/CB-1892


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/4864283b
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/4864283b
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/4864283b

Branch: refs/heads/master
Commit: 4864283bcc17d37d7d28d85ffed9dc41dd3931f9
Parents: f81be66
Author: Andrew Grieve <agrieve@chromium.org>
Authored: Thu Nov 22 15:40:43 2012 -0500
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Thu Nov 22 15:45:06 2012 -0500

----------------------------------------------------------------------
 lib/common/plugin/resolveLocalFileSystemURI.js |   17 ++++++-----------
 1 files changed, 6 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/4864283b/lib/common/plugin/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/resolveLocalFileSystemURI.js b/lib/common/plugin/resolveLocalFileSystemURI.js
index c83b0aa..0eac42d 100644
--- a/lib/common/plugin/resolveLocalFileSystemURI.js
+++ b/lib/common/plugin/resolveLocalFileSystemURI.js
@@ -19,7 +19,8 @@
  *
 */
 
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
+var argscheck = require('cordova/argscheck'),
+    DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
     FileEntry = require('cordova/plugin/FileEntry'),
     FileError = require('cordova/plugin/FileError'),
     exec = require('cordova/exec');
@@ -31,11 +32,10 @@ var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
  * @param errorCallback    invoked if error occurs retrieving file system entry
  */
 module.exports = function(uri, successCallback, errorCallback) {
+    argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
     // error callback
     var fail = function(error) {
-        if (typeof errorCallback === 'function') {
-            errorCallback(new FileError(error));
-        }
+        errorCallback && errorCallback(new FileError(error));
     };
     // sanity check for 'not:valid:filename'
     if(!uri || uri.split(":").length > 2) {
@@ -48,15 +48,10 @@ module.exports = function(uri, successCallback, errorCallback) {
     var success = function(entry) {
         var result;
         if (entry) {
-            if (typeof successCallback === 'function') {
+            if (successCallback) {
                 // create appropriate Entry object
                 result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath)
: new FileEntry(entry.name, entry.fullPath);
-                try {
-                    successCallback(result);
-                }
-                catch (e) {
-                    console.log('Error invoking callback: ' + e);
-                }
+                successCallback(result);
             }
         }
         else {


Mime
View raw message