UNPKG

@polygonjs/polygonjs

Version:

node-based WebGL 3D engine https://polygonjs.com

36 lines (35 loc) 842 B
"use strict"; import { NodeEvent } from "../../../poly/NodeEvent"; import { NodeBaseState } from "./Base"; import { Poly } from "../../../Poly"; export class NodeErrorState extends NodeBaseState { set(message) { if (this._message != message) { if (message) { Poly.error(`[${this.node.path()}] error: '${message}' (from '${this._message}')`); } else { Poly.warn(`[${this.node.path()}] clear error`); } this._message = message; this.onUpdate(); } } message() { return this._message; } clear() { this.set(void 0); } active() { return this._message != null; } onUpdate() { if (this._message != null) { this.node._setContainer( null /*, `from error '${this._message}'`*/ ); } this.node.emit(NodeEvent.ERROR_UPDATED); } }