我的哨兵设置如下:
void main() => runZonedGuarded(() {
runApp(MyApp());
}, (Object error, StackTrace stackTrace) {
reportError(error, stackTrace);
});
Run Code Online (Sandbox Code Playgroud)
及相关功能
final SentryClient sentry = new SentryClient(dsn: '<my-dsn>');
Future<void> reportError(dynamic error, dynamic stackTrace) async {
sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
}
Run Code Online (Sandbox Code Playgroud)
我throw Exception("my-error")在小部件的构建方法中添加了内容,但我看不到 Sentry Web 控制台上显示的错误。
我创建了一个文件来引发异常和哨兵捕获,并且我确实看到哨兵正在报告错误。
肯定有什么问题runZonedGuarded。
小智 1
import 'package:sentry/io_client.dart';
主程序.dart
import 'package:sentry/io_client.dart';
final SentryClient sentry = new SentryClient(dsn: YOUR_DSN);
main() async {
try {
throw new StateError('This is a Dart exception.');
} catch(error, stackTrace) {
await sentry.captureException(
exception: error,
stackTrace: stackTrace,
);
}
}
Run Code Online (Sandbox Code Playgroud)
主屏幕
floatingActionButton: FloatingActionButton(
onPressed: () async{
throw new StateError('This is a Dart exception.');
},
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3665 次 |
| 最近记录: |