fixed sentry crashes handling

This commit is contained in:
misha
2026-11-20 14:24:20 +03:00
parent 1e8c1ab2eb
commit 5308c11ca6
48 changed files with 909 additions and 136 deletions

View File

@@ -1,4 +1,5 @@
import 'package:dio/dio.dart';
import 'package:eatvio_app/core/error_reporting/api_response_error_reporter.dart';
import 'package:eatvio_app/features/chat/models/payment_model.dart';
import 'package:eatvio_app/features/chat/services/chat_service.dart';
import 'package:eatvio_app/features/payment/models/promo_applied_list_response.dart';
@@ -10,8 +11,9 @@ import 'package:eatvio_app/features/payment/models/promo_validate_response.dart'
/// Репозиторий оплаты консультаций (chosen_plan) через Alfa Bank / СБП.
class PaymentRepository {
final ChatService chatService;
final ApiResponseErrorReporter? responseErrors;
PaymentRepository({required this.chatService});
PaymentRepository({required this.chatService, this.responseErrors});
/// Запускает процесс оплаты: POST `/api/chosen_plans/{id}/start_payment_process`
/// с `payment_provider: alfa-bank`.
@@ -64,9 +66,15 @@ class PaymentRepository {
body: {'promo_code': promoCode},
);
} on DioException catch (e) {
final data = e.response?.data;
if (data is Map<String, dynamic>) {
return PromoApplyResponse.fromJson(data);
final response = e.response;
final data = response?.data;
if (response != null && data is Map<String, dynamic>) {
return ApiResponseErrorReporter.decode(
responseErrors,
response,
'/api/chosen_plans/{id}/apply_promo',
() => PromoApplyResponse.fromJson(data),
);
}
rethrow;
}
@@ -77,9 +85,15 @@ class PaymentRepository {
try {
return await chatService.removePromoCode(id: planId);
} on DioException catch (e) {
final data = e.response?.data;
if (data is Map<String, dynamic>) {
return PromoRemoveResponse.fromJson(data);
final response = e.response;
final data = response?.data;
if (response != null && data is Map<String, dynamic>) {
return ApiResponseErrorReporter.decode(
responseErrors,
response,
'/api/chosen_plans/{id}/remove_promo_code',
() => PromoRemoveResponse.fromJson(data),
);
}
rethrow;
}