UNPKG

@connectv/core

Version:

agent-based reactive programming library for typescript/javascript

60 lines 2.22 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var emission_1 = require("../emission"); /** * * Represents when an error has occured during handling an emission. * You can retrieve the emission that resulted in the error via `.emission` property, * and you can retrieve the original error via `.original` property. * */ var EmissionError = /** @class */ (function (_super) { __extends(EmissionError, _super); function EmissionError(original, emission) { var _this = _super.call(this, original instanceof Error ? original.message : original) || this; _this.emission = emission; if (original instanceof Error) _this.original = original; else _this.original = new Error(original); return _this; } Object.defineProperty(EmissionError.prototype, "message", { get: function () { return this.original.message; }, enumerable: true, configurable: true }); Object.defineProperty(EmissionError.prototype, "stack", { get: function () { return this.original.stack; }, enumerable: true, configurable: true }); return EmissionError; }(Error)); exports.EmissionError = EmissionError; /** * * Checks if an object is an `EmissionError` (this is needed due to some issues * with Typescript's typechecking on Errors). * */ function isEmissionError(err) { return err instanceof Error && err.original instanceof Error && err.emission instanceof emission_1.Emission; } exports.isEmissionError = isEmissionError; //# sourceMappingURL=emission-error.js.map