bbc / sqs-consumer

Build Amazon Simple Queue Service (SQS) based applications without the boilerplate
https://bbc.github.io/sqs-consumer/
Other
1.74k stars 333 forks source link

TypeError when handler throws not standard error #276

Closed maxdelemos closed 1 year ago

maxdelemos commented 3 years ago

The problem When handler throws not standard error.

consumer.ts

  private async executeBatchHandler(messages: SQSMessage[]): Promise<void> {
    try {
      await this.handleMessageBatch(messages);
    } catch (err) {
      err.message = `Unexpected message handler failure: ${err.message}`;
      throw err;
    }
  }

Suggested solution We could check the type of error at this catch.

Alternatives considered

  private async executeBatchHandler(messages: SQSMessage[]): Promise<void> {
    try {
      await this.handleMessageBatch(messages);
    } catch (err) {
        if (err instanceof Error) {
            err.message = `Unexpected message handler failure: ${err.message}`;
        }
        throw err;
    }
  }

Additional context I found a related issue in executeHandler that was resolved here #235

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.