vstirbu/fsm-as-promised

`Invalid event in current state` error handling

vstirbu opened this issue · 1 comments

The library is not able to distinguish between Invalid event in current state errors thrown by different fsm instances:

const other = StateMachine({
  initial: 'one',
  events: [
    { name: 'init', from: 'one', to: 'two' },
    { name: 'crash', from: 'two' }
  ]
});

const fsm = StateMachine({
  initial: 'here',
  events: [
    { name: 'stay', from: 'here' },
    { name: 'move', from: 'here', to: 'there' }
  ],
  callbacks: {
    onstay: function(opts) {
      // throws a FsmError from a different fsm instance
      return other.crash();
    }
  }
});

fsm.stay().catch((e) => {
  fsm.move(); // throws error
});

fixed by f129f82