mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 20:07:30 +09:00
Issue #1208: Fix jsonLoad in Sync's util.js to handle errors.
- `OS.Path.join` can throw, so we always need to try/catch it. - Also do a sanity check to make sure `callback` is defined before use
This commit is contained in:
parent
bd9bb12027
commit
c0204d7955
1 changed files with 12 additions and 4 deletions
|
|
@ -321,10 +321,17 @@ this.Utils = {
|
||||||
* could not be loaded, the first argument will be undefined.
|
* could not be loaded, the first argument will be undefined.
|
||||||
*/
|
*/
|
||||||
jsonLoad: Task.async(function*(filePath, that, callback) {
|
jsonLoad: Task.async(function*(filePath, that, callback) {
|
||||||
let path = OS.Path.join(OS.Constants.Path.profileDir, "weave", filePath + ".json");
|
let path;
|
||||||
|
try {
|
||||||
|
path = OS.Path.normalize(OS.Path.join(OS.Constants.Path.profileDir, "weave", filePath + ".json"));
|
||||||
|
} catch (e) {
|
||||||
|
if (that._log) {
|
||||||
|
that._log.debug("Path join error: " + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (that._log) {
|
if (that._log) {
|
||||||
that._log.trace("Loading json from disk: " + filePath);
|
that._log.trace("Loading json from disk: " + path);
|
||||||
}
|
}
|
||||||
|
|
||||||
let json;
|
let json;
|
||||||
|
|
@ -341,8 +348,9 @@ this.Utils = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (callback) {
|
||||||
callback.call(that, json);
|
callback.call(that, json);
|
||||||
|
}
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue