如何捕捉所有未捕获的错误在dart聚合物应用程序? [英] How to catch all uncaught errors in a dart polymer app?

查看:99
本文介绍了如何捕捉所有未捕获的错误在dart聚合物应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想要一个处理程序来捕获Polymer应用程序中所有未处理的错误。 Zone

  void main ){
runZoned(()=> initPolymer(),onError:(e,stackTrace){
_log.shout('TOP ZONE',e,stackTrace);
}
}

但这不行。错误从未到达此错误处理程序。



不确定这是否涉及 http://code.google.com/p/dart/issues/detail?id=15854



如何处理此问题?

解决方案

如何使用 Window.onError

  import'dart:html'; 

main(){
window.onError.listen((ErrorEvent e)=> print(e.message));
throw'boom!';
}


I want to put in a handler that will catch all unhandled errors in a Polymer app.

I figured Zone would be the trick so tried

void main() {
  runZoned(() => initPolymer(), onError: (e, stackTrace) {
    _log.shout('TOP ZONE', e, stackTrace);
  });
}

But that doesn't work. The errors never get to this error handler.

Not sure if this relates to http://code.google.com/p/dart/issues/detail?id=15854

How do people handle this?

解决方案

How about using Window.onError.

import 'dart:html';

main() {
  window.onError.listen((ErrorEvent e) => print(e.message));
  throw 'boom!';
}

这篇关于如何捕捉所有未捕获的错误在dart聚合物应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆