[英]Flex/AIR - Displaying ActionScript errors in a release application
当我在调试模式下运行Flex / AIR应用程序并发生错误时,我看到以下信息:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
但是,当应用程序已作为发行版安装并发生相同的错误时,我看不到错误消息。
我的应用程序是否可以将这些类型的错误保存到日志文件或通过电子邮件发送给我?
我已经使用UncaughtErrorEvent和airxmail类自己实现了这一点。
这是将UncaughtError事件添加到loaderInfo的简单情况(在FlexEvent.APPLICATION_COMPLETE事件调用的方法内)。 使用这两个类,应用程序会在发布模式下将发生的运行时错误通过电子邮件发送给我,仅当UncaughtError事件在调试模式下不会触发时才在发布模式下发送给我。
如果要记录未捕获的错误,则可以使用uncaughtError事件。
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR,handleGlobalErrors);
function handleGlobalErrors( evt : UncaughtErrorEvent ):void
{
//code that saves error to log or send by email..
evt.preventDefault();
}
您可以在http://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/events/UncaughtErrorEvent.html上找到有关此功能的更多信息。
还要注意,如果在调试模式下使用此功能,则handleGlobalErrors函数会捕获所有错误,因此请记住这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.