1
0

Show a clear error message when querying a non-existant query source

This commit is contained in:
Zef Hemel 2023-01-26 15:52:37 +01:00
parent d133c79de0
commit 4c39d0b964

View File

@ -18,15 +18,18 @@ export async function queryDirectiveRenderer(
JSON.parse(replaceTemplateVars(JSON.stringify(query), pageName)),
);
const eventName = `query:${parsedQuery.table}`;
// console.log("Parsed query", parsedQuery);
// Let's dispatch an event and see what happens
const results = await events.dispatchEvent(
`query:${parsedQuery.table}`,
eventName,
{ query: parsedQuery, pageName: pageName },
30 * 1000,
);
if (results.length === 0) {
return "";
// This means there was no handler for the event which means it's unsupported
return `**Error:** Unsupported query source '${parsedQuery.table}'`;
} else if (results.length === 1) {
if (parsedQuery.render) {
const rendered = await renderTemplate(parsedQuery.render, results[0]);