forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrobust-integration-example.ts
More file actions
40 lines (36 loc) · 1.16 KB
/
Copy pathrobust-integration-example.ts
File metadata and controls
40 lines (36 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { Injectable } from "@nestjs/common";
import { ActivitiesService } from "./activities.service";
/**
* Example 6: Error Handling and Graceful Degradation
* Activity tracking should not break core functionality
*/
@Injectable()
export class RobustIntegrationExample {
constructor(private readonly activitiesService: ActivitiesService) {}
async processPaymentWithGracefulTracking(
userId: string,
splitId: string,
amount: number,
txHash: string
) {
// Core payment processing
// const paymentResult = await this.stellarService.submitPayment(...);
// Track activity, but don't let tracking failures affect payment
try {
await this.activitiesService.trackPaymentMade(
userId,
splitId,
amount,
txHash,
{ timestamp: new Date().toISOString() }
);
} catch (error) {
// Log the error but don't throw
console.error("Failed to track activity:", error);
// Optionally send to error monitoring service
// await this.errorMonitoring.captureException(error);
}
// Return payment result regardless of tracking status
return { success: true, txHash };
}
}