NativeScript / NativeScript/NativeScript

Rework error handling for synchronous file system module API

Open
#6,260 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
25.7k
Forks
1.7k
Avg merge
1d 5h
Merged PRs (30d)
35

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the synchronous file-system module API, especially the writeTextSync entry point shown in the issue, and inspect how sync methods currently consume their final error callbacks. Review the related tests and the Node.js fs behavior before checking each sync method. Done means sync methods no longer require optional error callbacks and failures are handled through try...catch-compatible errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, operating-systems
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.