UNPKG

@connectv/core

Version:

agent-based reactive programming library for typescript/javascript

32 lines 1.05 kB
import { Emission } from '../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. * */ export class EmissionError extends Error { constructor(original, emission) { super(original instanceof Error ? original.message : original); this.emission = emission; if (original instanceof Error) this.original = original; else this.original = new Error(original); } get message() { return this.original.message; } get stack() { return this.original.stack; } } /** * * Checks if an object is an `EmissionError` (this is needed due to some issues * with Typescript's typechecking on Errors). * */ export function isEmissionError(err) { return err instanceof Error && err.original instanceof Error && err.emission instanceof Emission; } //# sourceMappingURL=emission-error.js.map