sqs-consumer
sqs-consumer copied to clipboard
TypeError when handler throws not standard error
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