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:
parent
146fccfa80
commit
9817b4963a
1 changed files with 4 additions and 1 deletions
|
|
@ -71,7 +71,10 @@ export const wotStoreModule = {
|
||||||
) => {
|
) => {
|
||||||
// Find the URL for a particular operation
|
// Find the URL for a particular operation
|
||||||
let td = state.thingDescriptions[thing];
|
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 affordances = td[affordanceType];
|
||||||
let href = findFormHref(affordances[affordance], op);
|
let href = findFormHref(affordances[affordance], op);
|
||||||
if (href == undefined) {
|
if (href == undefined) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue