Skip to content

Conversation

@ghost1542
Copy link

@ghost1542 ghost1542 commented May 22, 2018

window.addEventListener('error', is sending back ErrorEvent objects instead of Error objects.

Since the following code snippet only accepts instances of Error, the object is returned as is, and not much ends up serialized and sent back by preload.js, just a bunch of { isTrusted: true }.

/**
 * Make errors serializeable
 */

function error(err) {
  if (!(err instanceof Error)) return err <--------------------
  return {
    code: err.code,
    message: err.message,
    details: err.detail,
    stack: err.stack || ''
  }
}

Fixing preload.js to serialize and send the Error object instead appears to match the initial intent.

@ghost1542 ghost1542 changed the title Serialize and send page error intead of ErrorEvent Serialize and send page error instead of ErrorEvent May 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants