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.
This commit is contained in:
Richard Bowman 2023-12-01 21:14:24 +00:00
parent 146fccfa80
commit 9817b4963a

View file

@ -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) {