capability: on() without a function says what it got and what to pass
The message read "the handler of TurnOn is a function", which states the
opposite of what went wrong. It is now
on("TurnOff") got undefined as the handler: pass a function that takes
the context of the directive
under the endpoint and the interface, as every DeclarationError.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
2f6730eb52
commit
b083b23ab0
4 changed files with 11 additions and 5 deletions
5
dist/esm/device/Capability.js
vendored
5
dist/esm/device/Capability.js
vendored
|
|
@ -33,8 +33,9 @@ export class Capability {
|
|||
if (name !== "*" && this.descriptor.tier !== 3 && !names.includes(name)) {
|
||||
throw new DeclarationError(this, `${name} is not a directive of the interface, which has ${names.join(", ") || "none"}`);
|
||||
}
|
||||
if (typeof handler !== "function")
|
||||
throw new DeclarationError(this, `the handler of ${name} is a function`);
|
||||
if (typeof handler !== "function") {
|
||||
throw new DeclarationError(this, `on("${name}") got ${handler === null ? "null" : typeof handler} as the handler: pass a function that takes the context of the directive`);
|
||||
}
|
||||
this.handlers.set(name, handler);
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue