Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use external aggregate-error package to get better messages #73

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@aws-sdk/util-dynamodb": "^3.369.0",
"@types/aws-lambda": "^8.10.92",
"aggregate-error": "^3.0.0",
"lodash": "^4.17.21",
"p-map": "^4.0.0",
"uuid": "^8.3.2"
Expand Down
7 changes: 2 additions & 5 deletions src/dynamo-streams.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,8 @@ describe('DynamoStreamHandler', () => {
{} as any,
);
} catch (e: any) {
expect(e).toBeInstanceOf(AggregateError);
expect(e.errors).toEqual([
new Error('Failed to process new-insert-2'),
new Error('Failed to process new-insert-3'),
]);
expect(e.message).toContain('Failed to process new-insert-2');
expect(e.message).toContain('Failed to process new-insert-3');
}

expect(dataSources.doSomething).toHaveBeenCalledTimes(1);
Expand Down
7 changes: 2 additions & 5 deletions src/kinesis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,8 @@ describe('KinesisEventHandler', () => {
{} as any,
);
} catch (e: any) {
expect(e).toBeInstanceOf(AggregateError);
expect(e.errors).toEqual([
new Error('Failed to process test-event-2'),
new Error('Failed to process test-event-3'),
]);
expect(e.message).toContain('Failed to process test-event-2');
expect(e.message).toContain('Failed to process test-event-3');
}
});

Expand Down
11 changes: 6 additions & 5 deletions src/sqs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,12 @@ describe('SQSMessageHandler', () => {
{} as any,
);
} catch (e: any) {
expect(e).toBeInstanceOf(AggregateError);
expect(e.errors).toEqual([
new Error('Failed to process message test-event-3'),
new Error('Failed to process message test-event-7'),
]);
expect(e.message).toContain(
'Error: Failed to process message test-event-3',
);
expect(e.message).toContain(
'Error: Failed to process message test-event-7',
);
}
});

Expand Down
1 change: 1 addition & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { LoggerInterface } from '@lifeomic/logging';
import { Context } from 'aws-lambda';
import pMap from 'p-map';
import groupBy from 'lodash/groupBy';
import AggregateError from 'aggregate-error';

export type BaseContext = {
logger: LoggerInterface;
Expand Down
Loading