Skip to content
Merged
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
7 changes: 6 additions & 1 deletion src/api/withdrawal/withdrawal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,14 +353,19 @@ export class WithdrawalService {
);
} catch (e) {
this.logger.error(
`Failed to update payment processing state: ${e.message} for winnings '${winningsIds.join(',')}`,
`Failed to update payment processing state: ${e?.message} for winnings '${winningsIds.join(',')}`,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ correctness]
Using optional chaining (e?.message) is a good practice to avoid runtime errors if e is null or undefined. However, ensure that e is always an object in this context. If e can be a non-object type, consider adding a type guard or additional error handling to ensure that e.message is accessed safely.

);

// mark release as failed
await this.updateDbReleaseRecord(paymentRelease, {
status: 'FAILED',
});

await this.trolleyService.removePayment(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
Consider wrapping the removePayment call in a try-catch block to handle potential errors gracefully. If removePayment fails, it could leave the system in an inconsistent state, especially since an error is already being thrown immediately after.

trolleyPayment.id,
paymentBatch.id,
);

throw new Error('Failed to update payment processing state!');
}

Expand Down