mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-20 09:38:37 +08:00
Fix: Uncaught promise error #29
This commit is contained in:
@@ -15,8 +15,14 @@ export default class Console extends Tool
|
||||
super.init($el);
|
||||
|
||||
this._appendTpl();
|
||||
|
||||
this._initLogger();
|
||||
this._exposeLogger();
|
||||
this._rejectionHandler = e =>
|
||||
{
|
||||
this._logger.error(e.reason);
|
||||
};
|
||||
|
||||
this._initCfg(parent);
|
||||
this._bindEvent(parent);
|
||||
}
|
||||
@@ -60,6 +66,7 @@ export default class Console extends Tool
|
||||
this._origOnerror = window.onerror;
|
||||
|
||||
window.onerror = (errMsg, url, lineNum, column, errObj) => this._logger.error(errObj ? errObj : errMsg);
|
||||
window.addEventListener('unhandledrejection', this._rejectionHandler);
|
||||
|
||||
return this;
|
||||
}
|
||||
@@ -70,6 +77,7 @@ export default class Console extends Tool
|
||||
window.onerror = this._origOnerror;
|
||||
delete this._origOnerror;
|
||||
}
|
||||
window.removeEventListener('unhandledrejection', this._rejectionHandler);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -245,7 +245,8 @@ function formatErr(err)
|
||||
var lines = err.stack.split('\n'),
|
||||
msg = `${err.message || lines[0]}<br/>`;
|
||||
|
||||
lines = lines.filter(val => !regErudaJs.test(val));
|
||||
lines = lines.filter(val => !regErudaJs.test(val))
|
||||
.map(val => util.escape(val));
|
||||
|
||||
var stack = `<div class="eruda-stack eruda-hidden">${lines.slice(1).join('<br/>')}</div>`;
|
||||
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
<li>
|
||||
<a href="#" id="plugin">Plugin</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" id="issue29">#29</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<script>
|
||||
@@ -56,6 +59,16 @@
|
||||
};
|
||||
});
|
||||
});
|
||||
addClickEvent('issue29', function ()
|
||||
{
|
||||
new Promise(function (resolve, reject)
|
||||
{
|
||||
resolve();
|
||||
}).then(function (res)
|
||||
{
|
||||
var a = res.a;
|
||||
})
|
||||
});
|
||||
</script>
|
||||
<script>boot();</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user