added better error handling for missing action handlers
All checks were successful
Pull request change / publish (pull_request) Successful in 10s

This commit is contained in:
2025-11-06 18:44:04 -07:00
parent cfdcdf1def
commit 6f52c56857
2 changed files with 5 additions and 2 deletions

View File

@@ -8,7 +8,10 @@ export class Interactor {
constructor(initialReaction = new Reaction()) {
this.#actions.listen((action) => {
this[`_handle${action.constructor.name}`](action);
let funcRef = `_handle${action.constructor.name}`;
if (!this[funcRef])
throw `${this.constructor.name} does not have a handler defined for the action "${action.constructor.name}". Create one by adding a function definition named "${funcRef}" in the ${this.constructor.name} class.`;
this[funcRef](action);
});
this._react(initialReaction);
}