#1265 Add context to uncaught javascript exception

已合并
herby 2 年之前 将 1 次代码提交从 max/exception_handling合并至 amber/master
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      lang/base/kernel-runtime.js

+ 5 - 0
lang/base/kernel-runtime.js

@@ -343,6 +343,11 @@ define(['./junk-drawer'], function ($goodies) {
             function resultWithNoErrorHandling (worker) {
                 try {
                     return worker(thisContext);
+                } catch (error) {
+                    if (error.context == null) {
+                        error.context = thisContext;
+                    }
+                    throw error;                                
                 } finally {
                     thisContext = null;
                 }