added better error handling for missing action handlers
All checks were successful
Pull request change / publish (pull_request) Successful in 10s
All checks were successful
Pull request change / publish (pull_request) Successful in 10s
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user