feat: 错误自动上报机制
- 后端:error_reports 表 + POST /api/v1/public/errors + GET /api/v1/admin/errors - Flutter:ErrorReporter 单例,60s 去重,fire-and-forget,不影响用户 - main.dart:FlutterError 和 Zone 错误自动上报 - 打印异常:catch 块加 reportError,Windows 打印问题可自动采集堆栈 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||
import 'core/auth/auth_state.dart';
|
||||
import 'core/errors/error_reporter.dart';
|
||||
import 'core/router/app_router.dart';
|
||||
import 'core/theme/app_theme.dart';
|
||||
import 'providers/connectivity_provider.dart';
|
||||
@@ -15,6 +16,11 @@ void main() {
|
||||
debugPrint('═══ FlutterError ════════════════════════════');
|
||||
debugPrint(details.exceptionAsString());
|
||||
debugPrint(details.stack.toString());
|
||||
ErrorReporter.instance.report(
|
||||
errorType: ErrorType.flutterError,
|
||||
errorMsg: details.exceptionAsString(),
|
||||
stackTrace: details.stack,
|
||||
);
|
||||
};
|
||||
|
||||
runZonedGuarded(
|
||||
@@ -23,6 +29,11 @@ void main() {
|
||||
debugPrint('═══ Zone Error ═══════════════════════════════');
|
||||
debugPrint(error.toString());
|
||||
debugPrint(stack.toString());
|
||||
ErrorReporter.instance.report(
|
||||
errorType: ErrorType.zoneError,
|
||||
errorMsg: error.toString(),
|
||||
stackTrace: stack,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user