From 9817b4963af035a0eb4951f70d566821e3e1cc48 Mon Sep 17 00:00:00 2001 From: Richard Bowman Date: Fri, 1 Dec 2023 21:14:24 +0000 Subject: [PATCH] Handle missing Thing better in thingFormUrl We now give a helpful error message if the Thing is not found, rather than returning null. There's an argument to return `undefined` instead of raising an error, returning undefined is the default behaviour. --- webapp/src/wot-client.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webapp/src/wot-client.js b/webapp/src/wot-client.js index edfb5709..b1aa58d6 100644 --- a/webapp/src/wot-client.js +++ b/webapp/src/wot-client.js @@ -71,7 +71,10 @@ export const wotStoreModule = { ) => { // Find the URL for a particular operation let td = state.thingDescriptions[thing]; - if (!td) return null; + if (!td) { + if (allowUndefined) return undefined; + throw `Could not find form for ${affordanceType} ${thing}/${affordance} with op ${op}`; + } let affordances = td[affordanceType]; let href = findFormHref(affordances[affordance], op); if (href == undefined) {