From dbe48ea8a5d7010367e17c1692d55a40344dcfd4 Mon Sep 17 00:00:00 2001 From: garrettmills Date: Wed, 30 Mar 2022 17:24:45 -0500 Subject: [PATCH] Add debugging option to make bus warnings throw Error; bump version --- package.json | 2 +- src/support/bus/Bus.ts | 5 ++++- src/support/bus/LocalBus.ts | 5 ++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6a5c29a..e40ac7a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@extollo/lib", - "version": "0.9.6", + "version": "0.9.7", "description": "The framework library that lifts up your code.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/support/bus/Bus.ts b/src/support/bus/Bus.ts index fb3e9df..8bac60b 100644 --- a/src/support/bus/Bus.ts +++ b/src/support/bus/Bus.ts @@ -8,7 +8,7 @@ import { EventHandlerReturn, EventHandlerSubscription, } from './types' -import {Awaitable, Collection, Pipeline, uuid4} from '../../util' +import {Awaitable, Collection, ifDebugging, Pipeline, uuid4} from '../../util' import {Logging} from '../../service/Logging' import {Unit} from '../../lifecycle/Unit' import {Config} from '../../service/Config' @@ -185,6 +185,9 @@ export class Bus extends Unit implements EventBus< async up(): Promise { if ( this.isUp ) { this.logging.warn('Attempted to boot more than once. Skipping.') + ifDebugging('extollo.bus', () => { + throw new Error('Attempted to boot more than once. Skipping.') + }) return } diff --git a/src/support/bus/LocalBus.ts b/src/support/bus/LocalBus.ts index 70d192f..ebc3c90 100644 --- a/src/support/bus/LocalBus.ts +++ b/src/support/bus/LocalBus.ts @@ -1,6 +1,6 @@ import {Inject, Injectable, StaticInstantiable} from '../../di' import {BusSubscriber, Event, EventBus, EventHandler, EventHandlerReturn, EventHandlerSubscription} from './types' -import {Awaitable, Collection, Pipeline, uuid4} from '../../util' +import {Awaitable, Collection, ifDebugging, Pipeline, uuid4} from '../../util' import {Logging} from '../../service/Logging' import {Bus, BusInternalSubscription} from './Bus' import {getEventName} from './getEventName' @@ -109,6 +109,9 @@ export class LocalBus extends CanonicalItemClass i async up(): Promise { if ( this.isUp ) { this.logging.warn('Attempted to boot more than once. Skipping.') + ifDebugging('extollo.bus', () => { + throw new Error('Attempted to boot more than once. Skipping.') + }) return }