如何在本机反应中捕获未捕获的异常(全局) [英] how to catch uncaught exception (globally) in react native
本文介绍了如何在本机反应中捕获未捕获的异常(全局)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有谁知道捕获所有未捕获异常(全局)以便我可以将崩溃报告发送回服务器的最佳方法是什么?我似乎无法在 react native docs 或 github 上找到任何信息.
Does anyone know what is the best way to catch all uncaught exception (globally) so that I can send a crash report back to the server? I don't seem to be able to find any information on the react native docs or on github.
推荐答案
您可能会覆盖 React Native 用于开发的异常日志记录:
You could possibly override the exception logging that React Native uses for development:
ErrorUtils.setGlobalHandler(function() {
// your handler here
});
然后,您可能需要编写一些向 JS 公开的 Obj-C,具体取决于您的具体要求.
You may then need to write some Obj-C which you expose to JS, depending on your exact requirements.
这篇关于如何在本机反应中捕获未捕获的异常(全局)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文