diff --git a/src/query-bus.ts b/src/query-bus.ts index 39666bb3..dd7890e7 100644 --- a/src/query-bus.ts +++ b/src/query-bus.ts @@ -59,7 +59,8 @@ export class QueryBus const queryId = this.getQueryId(query); const handler = this.handlers.get(queryId); if (!handler) { - throw new QueryHandlerNotFoundException(queryId); + const queryName = this.getQueryName(query); + throw new QueryHandlerNotFoundException(queryName); } this._publisher.publish(query); @@ -120,4 +121,9 @@ export class QueryBus private useDefaultPublisher() { this._publisher = new DefaultQueryPubSub(this.subject$); } + + private getQueryName(query: QueryBase): string { + const { constructor } = Object.getPrototypeOf(query); + return constructor.name as string; + } }