Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assign getLayer template error message; catch and log error in addLayer #1383

Merged
merged 2 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading