зеркало из https://github.com/mozilla/gecko-dev.git
Bug 918364 - Make exceptions more meaningful in OS.File. r=froydnj
This commit is contained in:
Родитель
fd839e0c8e
Коммит
06b090bf96
|
@ -208,9 +208,16 @@ let Scheduler = {
|
|||
// Decode any serialized error
|
||||
if (error instanceof PromiseWorker.WorkerError) {
|
||||
throw OS.File.Error.fromMsg(error.data);
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
// Extract something meaningful from WorkerErrorEvent
|
||||
if (typeof error == "object" && error && error.constructor.name == "WorkerErrorEvent") {
|
||||
let message = error.message;
|
||||
if (message == "uncaught exception: [object StopIteration]") {
|
||||
throw StopIteration;
|
||||
}
|
||||
throw new Error(message, error.filename, error.lineno);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@ -965,14 +972,11 @@ DirectoryIterator.prototype = {
|
|||
promise = promise.then(
|
||||
DirectoryIterator.Entry.fromMsg,
|
||||
function onReject(reason) {
|
||||
// If the exception is |StopIteration| (which we may determine only
|
||||
// from its message...) we need to stop the iteration.
|
||||
if (!(reason instanceof WorkerErrorEvent && reason.message == "uncaught exception: [object StopIteration]")) {
|
||||
// Any exception other than StopIteration should be propagated as such
|
||||
throw reason;
|
||||
if (reason == StopIteration) {
|
||||
self.close();
|
||||
throw StopIteration;
|
||||
}
|
||||
self.close();
|
||||
throw StopIteration;
|
||||
throw reason;
|
||||
});
|
||||
return promise;
|
||||
},
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
Components.utils.import("resource://gre/modules/osfile.jsm");
|
||||
|
||||
function run_test() {
|
||||
do_test_pending();
|
||||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(function test_typeerror() {
|
||||
let exn;
|
||||
try {
|
||||
let fd = yield OS.File.open("/tmp", {no_such_key: 1});
|
||||
do_print("Fd: " + fd);
|
||||
} catch (ex) {
|
||||
exn = ex;
|
||||
}
|
||||
do_print("Exception: " + exn);
|
||||
do_check_true(typeof exn == "object");
|
||||
do_check_true("name" in exn);
|
||||
do_check_true(exn.message.indexOf("TypeError") != -1);
|
||||
});
|
||||
|
||||
add_task(function() {
|
||||
do_test_finished();
|
||||
});
|
|
@ -8,5 +8,6 @@ tail =
|
|||
[test_profiledir.js]
|
||||
[test_logging.js]
|
||||
[test_creationDate.js]
|
||||
[test_exception.js]
|
||||
[test_path_constants.js]
|
||||
[test_removeDir.js]
|
||||
|
|
Загрузка…
Ссылка в новой задаче