more detailed error messages

This commit is contained in:
Ulf Gebhardt 2023-02-07 18:24:20 +01:00
parent ff335d81f3
commit 0b8ac928cf
Signed by: ulfgebhardt
GPG Key ID: DA6B843E748679C9
2 changed files with 26 additions and 10 deletions

View File

@ -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'),
)
})

View File

@ -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()
}