Currently the error handling for the synchronous file system module API is performed via optional error callbacks that are passed as last parameter to the respective "sync" method. This approach is rather unconventional and unintuitive:
file.writeTextSync("some text", (err) => console.log(err));
Rework the error handling logic for the "sync" methods to be similar to the nodejs approach with try...catch blocks:
try {
file.writeTextSync("some text");
} catch (err) {
console.log(err);
}
Related to https://github.com/NativeScript/docs/issues/1111
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Totally agree the API with try/catch is much better.
Maybe we can implement a back-compatible approach. For example, if an error occurs
errorCallback - just call it and leave the user to handle it (the old way)Yup, we can do that but I would still remove the "old" way from our documentation / examples.
Please support the old way; there are several plugins in the ecosystem that use the FS module for things; and I know I don't really want to make the plugins incompatible with people still using NS 4...
Most helpful comment
Yup, we can do that but I would still remove the "old" way from our documentation / examples.