From 4c39d0b9647ad9aca834d68e9d03b5558ae699c9 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 26 Jan 2023 15:52:37 +0100 Subject: [PATCH] Show a clear error message when querying a non-existant query source --- plugs/directive/query_directive.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/plugs/directive/query_directive.ts b/plugs/directive/query_directive.ts index a3eb4d7..89cb4fd 100644 --- a/plugs/directive/query_directive.ts +++ b/plugs/directive/query_directive.ts @@ -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]);