[DEBUG] 异常诱因日志

记录异常诱因,详见 https://github.com/tc39/proposal-error-cause

目前为 2021-09-25 提交的版本。查看 最新版本

// ==UserScript==
// @name                  [DEBUG] LogExceptionCause
// @name:zh-CN            [DEBUG] 异常诱因日志
// @version               1.0.0.20210925
// @namespace             laster2800
// @author                Laster2800
// @description           Log exception cause, see https://github.com/tc39/proposal-error-cause
// @description:zh-CN     记录异常诱因,详见 https://github.com/tc39/proposal-error-cause
// @homepageURL           https://gf.qytechs.cn/zh-CN/scripts/432924
// @supportURL            https://gf.qytechs.cn/zh-CN/scripts/432924/feedback
// @license               LGPL-3.0
// @include               *
// @grant                 none
// @run-at                document-start
// ==/UserScript==

(function() {
  'use strict'

  window.addEventListener('error', log)
  window.addEventListener('unhandledrejection', log)

  function log(event) {
    const cause = (event.error ?? event.reason)?.cause
    if (cause !== undefined) {
      console.error('↓ Error is caused by', cause)
    }
  }
})()

QingJ © 2025

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