HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //var/www/zaklada/html/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js
"use strict";
const util = require("util");
const setErrorEventValues = require("../error-event").setErrorEventValues;

const errorReportingMode = Symbol("error reporting mode");

// https://html.spec.whatwg.org/multipage/webappapis.html#report-the-error
// Omits script parameter and any check for muted errors; takes error object, message, and location as params, unlike
// the spec. Returns whether the event was handled or not.
function reportAnError(line, col, target, errorObject, message, location) {
  if (errorReportingMode in target) {
    return false;
  }

  target[errorReportingMode] = true;

  // TODO Events: use constructor directly, once they are no longer tied to a window.
  const event = new target.ErrorEvent("error", { bubbles: false, cancelable: true });
  setErrorEventValues(event, {
    message,
    filename: location,
    lineno: line,
    colno: col,
    error: errorObject
  });

  target.dispatchEvent(event);

  delete target[errorReportingMode];

  return event._canceled;
}

module.exports = function reportException(window, error, filenameHint) {
  // This function will give good results on real Error objects with stacks; poor ones otherwise

  const stack = error && error.stack;
  const lines = stack && stack.split("\n");

  // Find the first line that matches; important for multi-line messages
  let pieces;
  if (lines) {
    for (let i = 1; i < lines.length && !pieces; ++i) {
      pieces = lines[i].match(/at (?:(.+)\s+)?\(?(?:(.+?):(\d+):(\d+)|([^)]+))\)?/);
    }
  }

  const fileName = pieces && pieces[2] || filenameHint || window._document._URL;
  const lineNumber = pieces && parseInt(pieces[3]) || 0;
  const columnNumber = pieces && parseInt(pieces[4]) || 0;

  const handled = reportAnError(lineNumber, columnNumber, window, error, error.message, fileName);

  if (!handled) {
    const jsdomError = new Error(`Uncaught ${util.inspect(error)}`);
    jsdomError.detail = error;

    window._virtualConsole.emit("jsdomError", jsdomError);
  }
};