[DEBUG] LogExceptionCause

Log exception cause, see https://github.com/tc39/proposal-error-cause

目前為 2021-09-25 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name [DEBUG] LogExceptionCause
  3. // @name:zh-CN [DEBUG] 异常诱因日志
  4. // @version 1.0.0.20210925
  5. // @namespace laster2800
  6. // @author Laster2800
  7. // @description Log exception cause, see https://github.com/tc39/proposal-error-cause
  8. // @description:zh-CN 记录异常诱因,详见 https://github.com/tc39/proposal-error-cause
  9. // @homepageURL https://gf.qytechs.cn/zh-CN/scripts/432924
  10. // @supportURL https://gf.qytechs.cn/zh-CN/scripts/432924/feedback
  11. // @license LGPL-3.0
  12. // @include *
  13. // @grant none
  14. // @run-at document-start
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict'
  19.  
  20. window.addEventListener('error', log)
  21. window.addEventListener('unhandledrejection', log)
  22.  
  23. function log(event) {
  24. const cause = (event.error ?? event.reason)?.cause
  25. if (cause !== undefined) {
  26. console.error('↓ Error is caused by', cause)
  27. }
  28. }
  29. })()

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址