Skip to content

Commit

Permalink
One more fix for #682, errors from fs had to be re-thrown.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwod committed Mar 3, 2021
1 parent d18a990 commit 6fbc9dd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion new-backend/server/api/services/config.service.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,14 @@ class ConfigServiceV2 {
// to figure out which layers are needed, and if UserSpecificMaps
// should be present.
const mapConfig = await this.getMapConfig(map, user, washContent);
if (mapConfig.error) throw mapConfig.error;

const layersStore = await this.getLayersStore(user, true);
if (layersStore.error) throw layersStore.error;
// Invoke the "cleaner" helper, expect only used layers in return.
const layersConfig = this.#removeUnusedLayersFromStore(
mapConfig,
await this.getLayersStore(user, true)
layersStore
);

// Finally, take a look in LayerSwitcher.options and see
Expand Down Expand Up @@ -417,6 +420,9 @@ class ConfigServiceV2 {
const text = await fs.promises.readFile(pathToFile, "utf-8");
const json = await JSON.parse(text);

if (text.error) throw text.error;
if (json.error) throw json.error;

// TODO:
// /config/layers should be way smarter than it is today. We should modify client
// so that we fetch mapconfig and layers at the same time. This way, we would be
Expand Down

0 comments on commit 6fbc9dd

Please sign in to comment.