Skip to content

Commit

Permalink
feat: add action value to no action error message in default handler …
Browse files Browse the repository at this point in the history
…and fix context on close event
  • Loading branch information
s.vyborov committed Mar 10, 2022
1 parent 44f2c8f commit faaba6e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ export class ServiceConnection extends EventEmitter {
this.handlers = {
[DEFAULT_ACTION]: async ({ message, ack }): Promise<void> => {
ack();
const { fields } = message; // TODO check for {}
log.error('[amqp-connection] No action for message', fields);
const { fields, properties: { headers: { action } } } = message; // TODO check for {}
const actionErrorMessage = action ? `No handler for action ${action}` : `Action is empty`
log.error(`[amqp-connection] ${actionErrorMessage} for message`, fields);
}
};
}
Expand Down Expand Up @@ -221,7 +222,7 @@ export class ServiceConnection extends EventEmitter {
connectionEventHandler(eventName: string, eventMessage: Message): void {
switch (eventName) {
case 'close':
this.handleConnectionClose(eventMessage).catch(this.log.error);
this.handleConnectionClose(eventMessage).catch(error => this.log.error(error));
break;
default:
this.log.warn({eventName, eventMessage}, '[amqp-connection] Unsupported connection event');
Expand Down

0 comments on commit faaba6e

Please sign in to comment.