jssm
Version:
A Javascript finite state machine (FSM) with a terse DSL and a simple API. Most FSMs are one-liners. Fast, easy, powerful, well tested, typed with TypeScript, and visualizations. MIT License.
28 lines (27 loc) • 1.14 kB
TypeScript
import { JssmErrorExtendedInfo } from './jssm_types';
/*******
*
* Custom error class for jssm. Enriches the standard `Error` with
* machine context (current state, instance name) and an optional
* `requested_state` so that error messages are self-describing.
*
* ```typescript
* throw new JssmError(machine, 'no such state', { requested_state: 'Blue' });
* // JssmError: [[my-light]]: no such state (at "Red", requested "Blue")
* ```
*
* @param machine - The `Machine` instance that raised the error, or
* `undefined` if no machine is available. Used to
* read `state()` and `instance_name()` for context.
* @param message - A human-readable description of the error.
* @param JEEI - Optional {@link JssmErrorExtendedInfo} with extra
* context such as `requested_state`.
*
*/
declare class JssmError extends Error {
message: string;
base_message: string;
requested_state: string | undefined;
constructor(machine: any, message: string, JEEI?: JssmErrorExtendedInfo);
}
export { JssmError };