Skip to content

Commit

Permalink
Merge pull request #41 from svyborov/add_info_to_no_action_log
Browse files Browse the repository at this point in the history
feat: add action value to no action error message in default handler
  • Loading branch information
alexkvak authored Mar 10, 2022
2 parents 44f2c8f + faaba6e commit f06f8c5
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 f06f8c5

Please sign in to comment.