diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts index 36d78c382..f3e5e865d 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.test.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.test.ts @@ -99,14 +99,18 @@ describe('ContributionMessageResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('ContributionMessage was not sent successfully')], + errors: [ + new GraphQLError( + 'ContributionMessage was not sent successfully: Error: Contribution not found', + ), + ], }), ) }) it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( - 'ContributionMessage was not sent successfully', + 'ContributionMessage was not sent successfully: Error: Contribution not found', new Error('Contribution not found'), ) }) @@ -135,14 +139,18 @@ describe('ContributionMessageResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('ContributionMessage was not sent successfully')], + errors: [ + new GraphQLError( + 'ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution', + ), + ], }), ) }) it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( - 'ContributionMessage was not sent successfully', + 'ContributionMessage was not sent successfully: Error: Admin can not answer on his own contribution', new Error('Admin can not answer on his own contribution'), ) }) @@ -229,14 +237,18 @@ describe('ContributionMessageResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('ContributionMessage was not sent successfully')], + errors: [ + new GraphQLError( + 'ContributionMessage was not sent successfully: Error: Contribution not found', + ), + ], }), ) }) it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( - 'ContributionMessage was not sent successfully', + 'ContributionMessage was not sent successfully: Error: Contribution not found', new Error('Contribution not found'), ) }) @@ -257,14 +269,18 @@ describe('ContributionMessageResolver', () => { }), ).resolves.toEqual( expect.objectContaining({ - errors: [new GraphQLError('ContributionMessage was not sent successfully')], + errors: [ + new GraphQLError( + 'ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user', + ), + ], }), ) }) it('logs the error thrown', () => { expect(logger.error).toBeCalledWith( - 'ContributionMessage was not sent successfully', + 'ContributionMessage was not sent successfully: Error: Can not send message to contribution of another user', new Error('Can not send message to contribution of another user'), ) }) diff --git a/backend/src/graphql/resolver/ContributionMessageResolver.ts b/backend/src/graphql/resolver/ContributionMessageResolver.ts index 3e6f86e53..4248946b1 100644 --- a/backend/src/graphql/resolver/ContributionMessageResolver.ts +++ b/backend/src/graphql/resolver/ContributionMessageResolver.ts @@ -54,7 +54,7 @@ export class ContributionMessageResolver { await queryRunner.commitTransaction() } catch (e) { await queryRunner.rollbackTransaction() - throw new LogError('ContributionMessage was not sent successfully', e) + throw new LogError(`ContributionMessage was not sent successfully: ${e}`, e) } finally { await queryRunner.release() } @@ -144,7 +144,7 @@ export class ContributionMessageResolver { await queryRunner.commitTransaction() } catch (e) { await queryRunner.rollbackTransaction() - throw new LogError('ContributionMessage was not sent successfully', e) + throw new LogError(`ContributionMessage was not sent successfully: ${e}`, e) } finally { await queryRunner.release() }