Skip to content

Commit

Permalink
Merge pull request #1383 from dbauszus-glx/getlayer-err
Browse files Browse the repository at this point in the history
Assign getLayer template error message; catch and log error in addLayer
  • Loading branch information
RobAndrewHurst authored Jul 18, 2024
2 parents b8aa916 + ed69195 commit a42ce74
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/mapview/addLayer.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export default async function (layers) {

const layer = mapp.utils.merge({}, this.locale.layer || {}, layers[i])

// The layer.err will be assigned from a failure to fetch a layer template.
if (layer.err) {
// Error for each of the array items.
layer.err.forEach(err => console.error(err))
}

layer.zIndex ??= i

layer.mapview = this;
Expand Down
11 changes: 10 additions & 1 deletion mod/workspace/getLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ module.exports = async (params) => {

let template = structuredClone(await getTemplate(workspace.templates[layer.template || layer.key]))

// Assign the error message to the template
template.err &&= [template.err.message];

// Merge the workspace template into the layer.
layer = merge(template, layer)
}
Expand All @@ -67,7 +70,13 @@ module.exports = async (params) => {
if (!Object.hasOwn(workspace.templates, key)) continue;

let template = structuredClone(await getTemplate(workspace.templates[key]))

// Assign the error message to the template
if (Array.isArray(template.err)) {
template.err = template.err.map(err => err.message)
} else {
template.err &&= [template.err.message];
}

// Merge the workspace template into the layer.
layer = merge(layer, template)
}
Expand Down

0 comments on commit a42ce74

Please sign in to comment.