Error handling for a simple 'fetch some data, then save the data' Node function
In my opinion it is much better to place the saveData call inside the first try-catch block.

This avoids calling saveData with an undefined value in case an exception occurs in calls to fetch or data.json, and gives the json variable a clean scope.

Depending on the granularity needed for error handling I would prefer to surround

await saveData(json);


with try-catch if necessary. However, a switch statement could also be a natural approach if you have a clear distinction on the exceptions thrown (e.g. error numbers).