You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ti...@apache.org on 2012/06/07 22:40:44 UTC
[22/48] js commit: error on non-existing file
error on non-existing file
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/24596e78
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/24596e78
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/24596e78
Branch: refs/heads/master
Commit: 24596e78f20dd8a1cf1e5e7f68957ff22dc6f95d
Parents: dabfc15
Author: Tim Kim <ti...@nitobi.com>
Authored: Wed May 30 16:00:05 2012 -0700
Committer: Tim Kim <ti...@nitobi.com>
Committed: Thu Jun 7 13:40:23 2012 -0700
----------------------------------------------------------------------
lib/playbook/plugin/playbook/FileReader.js | 21 ++++++++++++++++++++-
1 files changed, 20 insertions(+), 1 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/24596e78/lib/playbook/plugin/playbook/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/FileReader.js b/lib/playbook/plugin/playbook/FileReader.js
index 7d6d20d..475b860 100644
--- a/lib/playbook/plugin/playbook/FileReader.js
+++ b/lib/playbook/plugin/playbook/FileReader.js
@@ -112,9 +112,28 @@ FileReader.prototype.readAsText = function(file, encoding) {
blackberry.io.file.readFile(this.fileName, getFileContents, false);
}else{
+ // If DONE (cancelled), then don't do anything
+ if (me.readyState === FileReader.DONE) {
+ return;
+ }
+
+ // DONE state
+ me.readyState = FileReader.DONE;
+
+ me.result = null;
- // TODO: file doesn't exist - throw error
+ // Save error
+ me.error = new FileError(FileError.NOT_FOUND_ERR);
+ // If onerror callback
+ if (typeof me.onerror === "function") {
+ me.onerror(new ProgressEvent("error", {target:me}));
+ }
+
+ // If onloadend callback
+ if (typeof me.onloadend === "function") {
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
+ }
}
};