<commit_before>var Promise = require('es6-promise').Promise
var stackTrace = require('./stacktrace')
var frames = require('./frames')

var Exceptions = function () {

}

Exceptions.prototype.install = function () {
  window.onerror = function (msg, file, line, col, error) {
    processError.call(this, error, msg, file, line, col)
  }.bind(this)
}

Exceptions.prototype.uninstall = function () {
  window.onerror = null
}

Exceptions.prototype.processError = function (err) {
  processError(err)
}

function processError (error, msg, file, line, col) {
  if (msg === 'Script error.' && !file) {
    // ignoring script errors: See https://github.com/getsentry/raven-js/issues/41
    return
  }

  var exception = {
    'message': error ? error.message : msg,
    'type': error.name || null,
    'fileurl': file || null,
    'lineno': line || null,
    'colno': col || null
  }

  var resolveStackFrames

  if (error) {
    resolveStackFrames = stackTrace.fromError(error)
  } else {
    resolveStackFrames = new Promise(function (resolve, reject) {
      resolve([{
        'fileName': file,
        'lineNumber': line,
        'columnNumber': col
      }])
    })
  }

  resolveStackFrames.then(function (stackFrames) {<commit_msg>Don’t expect error object to be around on caught Exceptions<commit_after>var Promise = require('es6-promise').Promise
var stackTrace = require('./stacktrace')
var frames = require('./frames')

var Exceptions = function () {

}

Exceptions.prototype.install = function () {
  window.onerror = function (msg, file, line, col, error) {
    processError.call(this, error, msg, file, line, col)
  }.bind(this)
}

Exceptions.prototype.uninstall = function () {
  window.onerror = null
}

Exceptions.prototype.processError = function (err) {
  processError(err)
}

function processError (error, msg, file, line, col) {
  if (msg === 'Script error.' && !file) {
    // ignoring script errors: See https://github.com/getsentry/raven-js/issues/41
    return
  }

  var exception = {
    'message': error ? error.message : msg,
    'type': error ? error.name : null,
    'fileurl': file || null,
    'lineno': line || null,
    'colno': col || null
  }

  var resolveStackFrames

  if (error) {
    resolveStackFrames = stackTrace.fromError(error)
  } else {
    resolveStackFrames = new Promise(function (resolve, reject) {
      resolve([{
        'fileName': file,
        'lineNumber': line,
        'columnNumber': col
      }])
    })
  }

  resolveStackFrames.then(function (stackFrames) {
{'fraction_non_alphanumeric': 0.14421930870083433, 'fraction_numerical': 0.0023837902264600714, 'mean_word_length': 3.3264604810996565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4704170', 'n_tokens_mistral': 799, 'n_tokens_neox': 778, 'n_words': 196}