Skip to content

Commit e93530c

Browse files
committed
fix: update error formatting to use constructor name in AppSyncGraphQLResolver
1 parent 737248d commit e93530c

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

packages/event-handler/src/appsync-graphql/AppSyncGraphQLResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class AppSyncGraphQLResolver extends Router {
398398
#formatErrorResponse(error: unknown) {
399399
if (error instanceof Error) {
400400
return {
401-
error: `${error.name} - ${error.message}`,
401+
error: `${error.constructor.name} - ${error.message}`,
402402
};
403403
}
404404
return {

packages/event-handler/tests/unit/appsync-graphql/AppSyncGraphQLResolver.test.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,9 @@ import {
1010
import type { ErrorClass } from '../../../src/types/appsync-graphql.js';
1111
import { onGraphqlEventFactory } from '../../helpers/factories.js';
1212

13-
class ValidationError extends Error {
14-
constructor(message: string) {
15-
super(message);
16-
this.name = 'ValidationError';
17-
}
18-
}
19-
20-
class NotFoundError extends Error {
21-
constructor(message: string) {
22-
super(message);
23-
this.name = 'NotFoundError';
24-
}
25-
}
26-
27-
class DatabaseError extends Error {
28-
constructor(message: string) {
29-
super(message);
30-
this.name = 'DatabaseError';
31-
}
32-
}
13+
class ValidationError extends Error {}
14+
class NotFoundError extends Error {}
15+
class DatabaseError extends Error {}
3316

3417
describe('Class: AppSyncGraphQLResolver', () => {
3518
beforeEach(() => {

0 commit comments

Comments
 (0)