Skip to content
This repository was archived by the owner on Feb 14, 2020. It is now read-only.
This repository was archived by the owner on Feb 14, 2020. It is now read-only.

Add Support for ErrorEvent #7

@ilyaigpetrov

Description

@ilyaigpetrov

ErrorEvent has some useful properties about error that I would like to have.
This is how Errio.toObject(errorEvent) could look:

// window.addEventListener('error', (errorEvent) => {...});
{
  "message": "Uncaught TypeError: AHA!",
  "filename": "file:///home/ilyaigpetrov/Repos/web-ext-error-reporter/tmp/index.html",
  "lineno": 77,
  "colno": 9,
  "error": {
    "stack": "TypeError: AHA!\n    at HTMLButtonElement.foo (file:///home/ilyaigpetrov/Repos/web-ext-error-reporter/tmp/index.html:77:9)",
    "message": "AHA!",
    "name": "TypeError"
  },
  "type": "error"
}

If you try to feed it to Errio, it throws Cannot read property 'options' of undefined (message should be more informative).

There is also window.addEventListener('unhandledrejection"', (promiseRejectionEvent) => {...}) but the only useful props are reason and path. I'm fine extracting it myself.

Current Solution

  const excerpt = [
    'message', 'filename', 'lineno', 'colno', 'type',
  ].reduce((acc, prop) => {

    acc[prop] = errEv[prop];
    return acc;

  }, {
    error: Errio.toObject(
      errEv.error,
      { stack: true, private: true },
    ),
  });

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions