gingko / client

Gingko Writer. Tree-based writing software, written in Elm.
https://gingkowriter.com
MIT License
361 stars 49 forks source link

Code Review: File IO #169

Closed jjant closed 5 years ago

jjant commented 5 years ago

Description

I reviewed the file-io.js and its uses in main.js, no major issues were found, but several changes were made:


On error handling

The most important things in these two files are that the file-io.js function all had redundant, unnecessary try/catch clauses that looked like this:

function f() {
  try {
    functionThatMayThrow();
  } catch (error) {
    throw error;
  }
}

This is effectively the same as just:

function f() {
  functionThatMayThrow();
}

So I removed most of those. If you wanted to handle these errors, probably a better place to do it, is at the call site, I've added an example in main.js line 551.

AdrianoFerrari commented 5 years ago

Thanks @jjant ! Very thorough code review, I learned a great deal.

After testing them, I merged almost all your changes as is for file-io.js :+1:

As for the merge conflicts in main.js, I kept many of them as they were in my branch, because most of the changes there were stylistic, and I had made some breaking changes of my own in the meantime. Didn't want to mess with it too much at this point...

Again, many thanks! :smile: